summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
authorCyber <cyber.hf18@gmail.com>2025-12-18 22:05:12 +0100
committerGitHub <noreply@github.com>2025-12-18 22:05:12 +0100
commitc984dbbd3fc57588027172a4fa29d5ff007a51dd (patch)
tree4bb51b8e016dd55ed24567566c9ea3eb77cbb14b /src/util
parentchore: run prettier (again) (diff)
parentMore gateway trace (diff)
downloadserver-ts-c984dbbd3fc57588027172a4fa29d5ff007a51dd.tar.xz
Merge branch 'master' into feat/forwards
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util/Stopwatch.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/util/util/Stopwatch.ts b/src/util/util/Stopwatch.ts

index a52dcf95..1f83c847 100644 --- a/src/util/util/Stopwatch.ts +++ b/src/util/util/Stopwatch.ts
@@ -61,3 +61,10 @@ export async function timePromise<T>(fn: () => Promise<T>): Promise<{ result: T; const elapsed = stopwatch.elapsed(); return { result, elapsed }; } + +export function timeFunction<T>(fn: () => T): { result: T; elapsed: ElapsedTime } { + const stopwatch = Stopwatch.startNew(); + const result = fn(); + const elapsed = stopwatch.elapsed(); + return { result, elapsed }; +}