aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/util/split.ts
blob: 015f4d165c7e6798336ea341aa7e6551cd78f8a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
let startTime = 0;
let lastTime = 0;
let splits: Record<string, number> = {};

export function splitInit(): void {
  splits = {};
  startTime = Date.now();
  lastTime = startTime;
}

export function addSplit(name: string): void {
  splits[name] = Date.now() - lastTime;
  lastTime = Date.now();
}

export function getSplits(): any {
  return { splits, total: Date.now() - startTime };
}