24 lines
367 B
JavaScript
24 lines
367 B
JavaScript
|
const Utils = require("./util.js")
|
||
|
|
||
|
class Perf {
|
||
|
constructor() {
|
||
|
this.init();
|
||
|
}
|
||
|
|
||
|
init() {
|
||
|
this.perf = [];
|
||
|
this.ts = new Date().getTime();
|
||
|
}
|
||
|
|
||
|
profile(event) {
|
||
|
const ts = new Date().getTime();
|
||
|
this.perf.push(`${event}: ${ts - this.ts}ms`);
|
||
|
}
|
||
|
|
||
|
dump() {
|
||
|
Utils.log(`${JSON.stringify(this.perf)}`);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
module.exports = new Perf();
|