Merge pull request #157 from github/cschleiden/timer

Await operation in timer
This commit is contained in:
Christopher Schleiden
2023-02-21 11:25:25 -08:00
committed by GitHub
+5 -1
View File
@@ -1,8 +1,12 @@
import {log} from "@github/actions-languageservice/log";
export function timeOperation<T>(name: string, f: () => T): T {
export async function timeOperation<T>(name: string, f: () => T): Promise<T> {
const start = Date.now();
const result = f();
if (result instanceof Promise) {
await result;
}
const end = Date.now();
log(`${name} took ${end - start}ms`);