Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

example/jsperf/ui.js: report both slower by xx% and slower by a factor of X #161

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
14 changes: 12 additions & 2 deletions benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -1530,8 +1530,18 @@
result = bench.name || (_.isNaN(id) ? id : '<Test #' + id + '>');

if (error) {
result += ': ' + join(error);
} else {
var errorStr;
if (!_.isObject(error)) {
errorStr = String(error);
} else if (!_.isError(Error)) {
errorStr = join(error);
} else {
// Error#name and Error#message properties are non-enumerable.
errorStr = join(_.assign({ 'name': error.name, 'message': error.message }, error));
}
result += ': ' + errorStr;
}
else {
result += ' x ' + formatNumber(hz.toFixed(hz < 100 ? 2 : 0)) + ' ops/sec ' + pm +
stats.rme.toFixed(2) + '% (' + size + ' run' + (size == 1 ? '' : 's') + ' sampled)';
}
Expand Down
2 changes: 1 addition & 1 deletion example/jsperf/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ footer {
width: 232px;
height: 39px;
filter: none;
background: url(//www.browserscope.org/static/img/logo.png) 0 0 no-repeat;
background: url(https://www.browserscope.org/static/img/logo.png) 0 0 no-repeat;
}

#bs-ua {
Expand Down
6 changes: 3 additions & 3 deletions example/jsperf/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@
addListener('run', 'click', handlers.button.run);

setHTML('run', texts.run.ready);
setHTML('user-agent', Benchmark.platform);
setStatus(texts.status.ready);

// prefill author details
Expand Down Expand Up @@ -561,10 +560,11 @@
if (_.indexOf(fastest, bench) > -1) {
// mark fastest
addClass(cell, text);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use a space, , instead of&#x00a0;?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent auto-wrapping the line between the times character and the factor itself, which would make it hard to read. This happened to me with some tests run using the customized jsperf example, so it'll happen to others too, I'm sure. ;-) Hence the non-breaking-space.

text += '<br>(&#x2715;&#x00a0;1)';
}
else {
text = isFinite(hz)
? formatNumber(percent < 1 ? percent.toFixed(2) : Math.round(percent)) + '% slower'
? formatNumber(percent < 1 ? percent.toFixed(2) : Math.round(percent)) + '% slower<br>(&#x2715;&#x00a0;' + (fastestHz / hz).toFixed(1) + ')'
: '';

// mark slowest
Expand Down Expand Up @@ -705,7 +705,7 @@
setTimeout(function() {
ui.off();
ui.browserscope.post = function() {};
_.invoke(ui.benchmarks, 'off');
_.invokeMap(ui.benchmarks, 'off');
}, 1);
}

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"test": "node test/test"
},
"dependencies": {
"lodash": "^4.13.1",
"lodash": "^4.14.0",
"platform": "^1.3.1"
},
"devDependencies": {
"coveralls": "^2.11.11",
"coveralls": "^2.11.12",
"docdown": "~0.6.1",
"istanbul": "0.4.4",
"qunit-extras": "^2.1.0",
"qunitjs": "^2.0.0",
"qunitjs": "^2.0.1",
"requirejs": "^2.2.0"
},
"files": [
Expand Down
8 changes: 4 additions & 4 deletions plugin/ui.browserscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
*/
function createSnapshot() {
// clone benches, exclude those that are errored, unrun, or have hz of Infinity
var benches = _.invoke(filter(ui.benchmarks, 'successful'), 'clone'),
var benches = _.invokeMap(filter(ui.benchmarks, 'successful'), 'clone'),
fastest = filter(benches, 'fastest'),
slowest = filter(benches, 'slowest');

Expand Down Expand Up @@ -578,7 +578,7 @@
setMessage(me.texts.loading);
// request Browserscope chart data and pass it to `google.visualization.Query.setResponse()`
(new visualization.Query(
'//www.browserscope.org/gviz_table_data?category=usertest_' + me.key + '&v=' + filterMap[filterBy],
'https://www.browserscope.org/gviz_table_data?category=usertest_' + me.key + '&v=' + filterMap[filterBy],
{ 'sendMethod': 'scriptInjection' }
))
.send(onComplete);
Expand Down Expand Up @@ -615,7 +615,7 @@
// set "posting" message and attempt to post the results snapshot
setMessage(me.texts.post);

// Note: We originally created an iframe to avoid Browerscope's old limit
// Note: We originally created an iframe to avoid Browserscope's old limit
// of one beacon per page load. It's currently used to implement custom
// request timeout and retry routines.
var idoc = win.frames[name].document;
Expand Down Expand Up @@ -728,7 +728,7 @@
!response && visualization && setMessage(me.texts.error);
retry(true);
}
// visualization chart gallary
// visualization chart gallery
// https://developers.google.com/chart/interactive/docs/gallery
else if (!ui.running) {
var data = cloneData(response.getDataTable()),
Expand Down