Await operation

This commit is contained in:
Christopher Schleiden
2023-02-17 16:16:16 -08:00
parent e6cd692ec0
commit 52fd34a684
+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`);