diff --git a/ui/templates.go b/ui/templates.go index 8dc9723..ca75c26 100644 --- a/ui/templates.go +++ b/ui/templates.go @@ -361,6 +361,8 @@ type TemplateRenderer struct{} * Standard Go error status. */ 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) if err != nil { diff --git a/util/logs.go b/util/logs.go new file mode 100644 index 0000000..56ff159 --- /dev/null +++ b/util/logs.go @@ -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)) + } +}