Skip to content

Commit bf8daac

Browse files
committed
Fix Benchmarker JS utility. NFC
1 parent d7fbee3 commit bf8daac

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ load('runtime.js');
8888
// Main
8989
// ===============================
9090

91-
B = new Benchmarker();
91+
global.B = new Benchmarker();
9292

9393
try {
9494
runJSify();

src/utility.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ function isPowerOfTwo(x) {
152152
function Benchmarker() {
153153
const totals = {};
154154
const ids = [];
155-
const lastTime = 0;
155+
const startTime = Date.now();
156+
let lastTime = 0;
156157
this.start = function(id) {
157158
const now = Date.now();
158159
if (ids.length > 0) {
@@ -172,8 +173,10 @@ function Benchmarker() {
172173
this.print = function(text) {
173174
const ids = Object.keys(totals);
174175
if (ids.length > 0) {
176+
const now = Date.now();
175177
ids.sort((a, b) => totals[b] - totals[a]);
176178
printErr(text + ' times: \n' + ids.map((id) => id + ' : ' + totals[id] + ' ms').join('\n'));
179+
printErr(`total: ${now - startTime}`);
177180
}
178181
};
179182
}

0 commit comments

Comments
 (0)