1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +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}`);
}