mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Add percent faster than to pref.js results and link to benchmarks in README.md.
Former-commit-id: 1c5fb820fe070599aba780f1765538d408105af3
This commit is contained in:
@@ -6,7 +6,7 @@ Lo-Dash’s performance is gained by avoiding slower native methods, instead opt
|
||||
|
||||
## Dive in
|
||||
|
||||
We’ve got [API docs](http://lodash.com/docs) and [unit tests](http://lodash.com/tests).
|
||||
We’ve got [API docs](http://lodash.com/docs), [benchmarks](http://lodash.com/benchmarks), and [unit tests](http://lodash.com/tests).
|
||||
|
||||
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/lodash/wiki/Roadmap).
|
||||
|
||||
|
||||
14
perf/perf.js
14
perf/perf.js
@@ -99,8 +99,8 @@
|
||||
lodashHz = underscoreHz = Math.min(lodashHz, underscoreHz);
|
||||
}
|
||||
else {
|
||||
var slowestHz = slowest[0] == this[0] ? lodashHz : underscoreHz,
|
||||
fastestHz = fastest[0] == this[0] ? lodashHz : underscoreHz,
|
||||
var fastestHz = fastest[0] == this[0] ? lodashHz : underscoreHz,
|
||||
slowestHz = slowest[0] == this[0] ? lodashHz : underscoreHz,
|
||||
percent = Math.round(((fastestHz / slowestHz) - 1) * 100);
|
||||
|
||||
console.log(fastest[0].name + ' is ' + percent + '% faster.');
|
||||
@@ -117,11 +117,17 @@
|
||||
suites[0].run();
|
||||
}
|
||||
else {
|
||||
var fastestTotalHz = Math.max(score.lodash, score.underscore),
|
||||
slowestTotalHz = Math.min(score.lodash, score.underscore),
|
||||
totalPercent = Math.round(((fastestTotalHz / slowestTotalHz) - 1) * 100),
|
||||
totalX = (fastestTotalHz / slowestTotalHz).toFixed(2),
|
||||
message = ' is ' + totalPercent + '% (' + totalX + 'x) faster than ';
|
||||
|
||||
// report results
|
||||
if (score.lodash >= score.underscore) {
|
||||
console.log('\nLo-Dash is ' + (score.lodash / score.underscore).toFixed(2) + 'x faster than Underscore.');
|
||||
console.log('\nLo-Dash' + message + 'Underscore.');
|
||||
} else {
|
||||
console.log('\nUnderscore is ' + (score.underscore / score.lodash).toFixed(2) + 'x faster than Lo-Dash.');
|
||||
console.log('\nUnderscore' + message + 'Lo-Dash.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user