tracing down high latency in Profile page, at least the first time...

This commit is contained in:
2026-03-24 23:20:17 -06:00
parent f94918a22b
commit e16110dd5a
2 changed files with 29 additions and 0 deletions
+2
View File
@@ -361,6 +361,8 @@ type TemplateRenderer struct{}
* Standard Go error status. * Standard Go error status.
*/ */
func (r *TemplateRenderer) Render(w io.Writer, name string, data any, c echo.Context) error { func (r *TemplateRenderer) Render(w io.Writer, name string, data any, c echo.Context) error {
defer util.MeasureTime(fmt.Sprintf("ui.Render(%s)", name))()
view, err := views.GetTemplate(name) view, err := views.GetTemplate(name)
if err != nil { if err != nil {
+27
View File
@@ -0,0 +1,27 @@
/*
* Amsterdam Web Communities System
* Copyright (c) 2025 Erbosoft Metaverse Design Solutions, All Rights Reserved
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*/
// Package util contains utility definitions.
package util
import (
"time"
log "github.com/sirupsen/logrus"
)
// MeasureTime is called via a defer, and prints the amount of time for a function.
func MeasureTime(funcName string) func() {
start := time.Now()
return func() {
log.Debugf("-- Time for function \"%s\" is %v", funcName, time.Since(start))
}
}