Skip to content

Commit c1851d9

Browse files
authored
use default performance.measure implementation (#83)
D8 now supports a more web-conformant performance.measure API. This PR changes the code to use performance.measure directly instead of using the wrapper.
1 parent 3bfe58c commit c1851d9

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

JetStreamDriver.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ class Benchmark {
650650
__benchmark.runIteration();
651651
let end = performance.now();
652652
653-
performanceMeasure(iterationMarkLabel, iterationStartMark);
653+
performance.measure(iterationMarkLabel, iterationMarkLabel);
654654
655655
${this.postIterationCode}
656656
@@ -718,19 +718,11 @@ class Benchmark {
718718
const isInBrowser = ${isInBrowser};
719719
const isD8 = ${isD8};
720720
if (typeof performance.mark === 'undefined') {
721-
performance.mark = function() {};
721+
performance.mark = function(name) { return { name }};
722722
}
723723
if (typeof performance.measure === 'undefined') {
724724
performance.measure = function() {};
725725
}
726-
function performanceMeasure(name, mark) {
727-
// D8 does not implement the official web API.
728-
// Also the performance.mark polyfill returns an undefined mark.
729-
if (isD8 || typeof mark === "undefined")
730-
performance.measure(name, mark);
731-
else
732-
performance.measure(name, mark.name);
733-
}
734726
`);
735727

736728
if (!!this.plan.deterministicRandom) {
@@ -1181,7 +1173,7 @@ class AsyncBenchmark extends DefaultBenchmark {
11811173
await __benchmark.runIteration();
11821174
let end = performance.now();
11831175
1184-
performanceMeasure(iterationMarkLabel, iterationStartMark);
1176+
performance.measure(iterationMarkLabel, iterationMarkLabel);
11851177
11861178
${this.postIterationCode}
11871179
@@ -1280,7 +1272,7 @@ class WSLBenchmark extends Benchmark {
12801272
benchmark.buildStdlib();
12811273
results.push(performance.now() - start);
12821274
1283-
performanceMeasure(markLabel, startMark);
1275+
performance.measure(markLabel, markLabel);
12841276
}
12851277
12861278
{
@@ -1291,7 +1283,7 @@ class WSLBenchmark extends Benchmark {
12911283
benchmark.run();
12921284
results.push(performance.now() - start);
12931285
1294-
performanceMeasure(markLabel, startMark);
1286+
performance.measure(markLabel, markLabel);
12951287
}
12961288
12971289
top.currentResolve(results);

0 commit comments

Comments
 (0)