tracing down high latency in Profile page, at least the first time...
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
@@ -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))
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user