Files
api/app/core/utils/debugging/debug-timer.ts
Alexis 010efe75bd Revert "chore: lint all the files"
This reverts commit 4ef387b5bb.
2021-09-07 13:46:23 +09:30

27 lines
565 B
TypeScript

/*!
* Copyright 2019-2020 Lime Technology Inc. All rights reserved.
* Written by: Alexis Tyler
*/
import { performance } from 'perf_hooks';
import { log } from '../../log';
const timers = new Map();
/**
* Debug timer
*/
export const debugTimer = (timerName: string): void => {
// Start new timer
if (!timers.has(timerName)) {
timers.set(timerName, performance.now());
return;
}
const timeLengthInMs = performance.now() - timers.get(timerName);
log.timer(`${timerName}: ${timeLengthInMs}`);
// Remove existing timer
timers.delete(timerName);
};