29 lines
614 B
JavaScript
29 lines
614 B
JavaScript
|
import { tableLogger } from "./logging";
|
||
|
|
||
|
export class Timeline {
|
||
|
constructor() {
|
||
|
this.startedAt = -1;
|
||
|
this.checkpoints = [];
|
||
|
this.logger = tableLogger("Timeline");
|
||
|
}
|
||
|
|
||
|
start() {
|
||
|
this.startedAt = performance.now();
|
||
|
this.checkpoints.push({
|
||
|
offset: 0,
|
||
|
label: "Timeline Started"
|
||
|
});
|
||
|
}
|
||
|
|
||
|
addCheckpoint(label) {
|
||
|
const offset = performance.now() - this.startedAt;
|
||
|
this.checkpoints.push({ offset, label });
|
||
|
}
|
||
|
|
||
|
dump() {
|
||
|
this.logger(this.checkpoints);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export const timeline = new Timeline();
|