Add actual performance API emulation for old browsers
This commit is contained in:
parent
1393681662
commit
2a367074fe
@ -31,9 +31,9 @@ body {
|
|||||||
var performance;
|
var performance;
|
||||||
if (typeof performance !== 'object') {
|
if (typeof performance !== 'object') {
|
||||||
performance = {
|
performance = {
|
||||||
mark: function() { },
|
mark: function(s) { this[s] = new Date() },
|
||||||
measure: function() { },
|
measure: function(_t, s1, s2) { this.t = this[s2] - this[s1] },
|
||||||
getEntriesByName: function() { return [ -1 ] }
|
getEntriesByName: function() { return [ { duration: this.t } ] }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +55,8 @@ function runTest(tname) {
|
|||||||
if (passed) {
|
if (passed) {
|
||||||
performance.mark('bench_end')
|
performance.mark('bench_end')
|
||||||
performance.measure('bench', 'bench_start', 'bench_end');
|
performance.measure('bench', 'bench_start', 'bench_end');
|
||||||
let duration = Math.round(performance.getEntriesByName('bench')[0].duration);
|
var duration = Math.round(performance.getEntriesByName('bench')[0].duration);
|
||||||
hn.appendChild(document.createTextNode(' - PASSED (time: ' + duration + ')'));
|
hn.appendChild(document.createTextNode(' - PASSED (time: ' + duration + ' ms)'));
|
||||||
hn.className = 'passed';
|
hn.className = 'passed';
|
||||||
} else {
|
} else {
|
||||||
hn.appendChild(document.createTextNode(' - FAILED'));
|
hn.appendChild(document.createTextNode(' - FAILED'));
|
||||||
|
Loading…
Reference in New Issue
Block a user