From e0ba7564f1326796e71e42e4c6e2dffcd9b6d51d Mon Sep 17 00:00:00 2001 From: Vyrtsev Mikhail Date: Sun, 7 Jul 2019 21:19:08 +0300 Subject: [PATCH] add bench util --- frontend/app/utils/bench.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 frontend/app/utils/bench.ts diff --git a/frontend/app/utils/bench.ts b/frontend/app/utils/bench.ts new file mode 100644 index 00000000..41a74fe1 --- /dev/null +++ b/frontend/app/utils/bench.ts @@ -0,0 +1,8 @@ +export function bench(fn: () => T, label: string = 'bench'): T { + const d = performance.now(); + const r = fn(); + const dd = performance.now(); + // eslint-disable-next-line no-console + console.info(label, dd - d); + return r; +}