1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/packages/utils/time.ts

23 lines
569 B
TypeScript

export const msleep = (ms: number) => {
return new Promise(resolve => setTimeout(resolve, ms));
};
// Use the utility functions below to easily measure performance of a block or
// line of code.
interface PerfTimer {
name: string;
startTime: number;
}
const perfTimers_: PerfTimer[] = [];
export function timerPush(name: string) {
perfTimers_.push({ name, startTime: Date.now() });
}
export function timerPop() {
const t = perfTimers_.pop() as PerfTimer;
// eslint-disable-next-line no-console
console.info(`Time: ${t.name}: ${Date.now() - t.startTime}`);
}