MCPcopy
hub / github.com/EverythingSuckz/TG-FileStreamBot / TimeFuncWithResult

Function TimeFuncWithResult

internal/utils/timing.go:10–17  ·  view source on GitHub ↗

TimeFuncWithResult wraps a function call and logs its execution time, returning a result

(log *zap.Logger, funcName string, fn func() (T, error))

Source from the content-addressed store, hash-verified

8
9// TimeFuncWithResult wraps a function call and logs its execution time, returning a result
10func TimeFuncWithResult[T any](log *zap.Logger, funcName string, fn func() (T, error)) (T, error) {
11 start := time.Now()
12 defer func() {
13 duration := time.Since(start).Milliseconds()
14 log.Debug(funcName+" executed", zap.Int64("duration_ms", duration))
15 }()
16 return fn()
17}

Callers 2

getStreamRouteFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected