Spaces:
Sleeping
Sleeping
Download internal/utils/timing.go from codebydante/BrodyFileStreamBot: direct link, hf CLI and curl.
- Browser
- Download file 438 Bytes
-
https://huggingface.co/spaces/codebydante/BrodyFileStreamBot/resolve/bd894b382ed6a42e3879e3846027d7e6d427f3f2/internal/utils/timing.go
- Command line
-
hf download hf://spaces/codebydante/BrodyFileStreamBot@bd894b382ed6a42e3879e3846027d7e6d427f3f2/internal/utils/timing.go
-
curl -L -o timing.go https://huggingface.co/spaces/codebydante/BrodyFileStreamBot/resolve/bd894b382ed6a42e3879e3846027d7e6d427f3f2/internal/utils/timing.go
438 Bytes
| package utils | |
| import ( | |
| "time" | |
| "go.uber.org/zap" | |
| ) | |
| // TimeFuncWithResult wraps a function call and logs its execution time, returning a result | |
| func TimeFuncWithResult[T any](log *zap.Logger, funcName string, fn func() (T, error)) (T, error) { | |
| start := time.Now() | |
| defer func() { | |
| duration := time.Since(start).Milliseconds() | |
| log.Debug(funcName+" executed", zap.Int64("duration_ms", duration)) | |
| }() | |
| return fn() | |
| } | |