Merge pull request #157 from github/cschleiden/timer
Await operation in timer
This commit is contained in:
@@ -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`);
|
||||
|
||||
Reference in New Issue
Block a user