mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Cleanup test.js and perf.js and add _(array) benchmark.
Former-commit-id: bcd120c9ee332db39c7b637894751f2861bac069
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
<body>
|
||||
<div id="perf-toolbar"></div>
|
||||
<script src="../vendor/platform.js/platform.js"></script>
|
||||
<script src="../lodash.js"></script>
|
||||
<script src="../vendor/benchmark.js/benchmark.js"></script>
|
||||
<script src="../vendor/firebug-lite/src/firebug-lite-debug.js"></script>
|
||||
<script src="perf-ui.js"></script>
|
||||
|
||||
57
perf/perf.js
57
perf/perf.js
@@ -25,27 +25,25 @@
|
||||
return result;
|
||||
}());
|
||||
|
||||
/** Load Benchmark.js */
|
||||
var Benchmark =
|
||||
window.Benchmark || (
|
||||
Benchmark = load('../vendor/benchmark.js/benchmark.js') || window.Benchmark,
|
||||
Benchmark.Benchmark || Benchmark
|
||||
);
|
||||
|
||||
/** Load Lo-Dash */
|
||||
var lodash =
|
||||
window.lodash || (
|
||||
lodash = load(filePath) || window._,
|
||||
lodash = lodash._ || lodash,
|
||||
lodash.noConflict()
|
||||
);
|
||||
var lodash = window.lodash || (window.lodash = (
|
||||
lodash = load(filePath) || window._,
|
||||
lodash = lodash._ || lodash,
|
||||
lodash.noConflict()
|
||||
));
|
||||
|
||||
/** Load Benchmark.js */
|
||||
var Benchmark = window.Benchmark || (window.Benchmark = (
|
||||
Benchmark = load('../vendor/benchmark.js/benchmark.js') || window.Benchmark,
|
||||
Benchmark = Benchmark.Benchmark || Benchmark,
|
||||
Benchmark.runInContext(lodash.extend({}, window, { '_': lodash }))
|
||||
));
|
||||
|
||||
/** Load Underscore */
|
||||
var _ =
|
||||
window._ || (
|
||||
_ = load('../vendor/underscore/underscore.js') || window._,
|
||||
_._ || _
|
||||
);
|
||||
var _ = window._ || (window._ = (
|
||||
_ = load('../vendor/underscore/underscore.js') || window._,
|
||||
_._ || _
|
||||
));
|
||||
|
||||
/** Used to access the Firebug Lite panel (set by `run`) */
|
||||
var fbPanel;
|
||||
@@ -68,16 +66,6 @@
|
||||
/** The other library basename */
|
||||
var otherName = basename(ui.otherPath, '.js');
|
||||
|
||||
/** Expose functions to the global object */
|
||||
window._ = _;
|
||||
window.Benchmark = Benchmark;
|
||||
window.lodash = lodash;
|
||||
|
||||
/** Add `console.log()` support for Narwhal and RingoJS */
|
||||
if (!window.console && window.print) {
|
||||
window.console = { 'log': window.print };
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@@ -201,8 +189,7 @@
|
||||
lodash.extend(Benchmark.options, {
|
||||
'async': true,
|
||||
'setup': '\
|
||||
var window = Function("return this || global")(),\
|
||||
_ = window._,\
|
||||
var _ = window._,\
|
||||
lodash = window.lodash,\
|
||||
belt = this.name == "Lo-Dash" ? lodash : _;\
|
||||
\
|
||||
@@ -471,6 +458,16 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_(...)` with an array')
|
||||
.add(buildName, '\
|
||||
lodash(numbers)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_(numbers)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_(...)` with an object')
|
||||
.add(buildName, '\
|
||||
|
||||
@@ -3,7 +3,7 @@ cd "$(dirname "$0")"
|
||||
echo "Running performance suite in node..."
|
||||
node perf.js ../dist/lodash.js && node perf.js ../dist/lodash.min.js
|
||||
|
||||
for cmd in rhino narwhal ringo phantomjs; do
|
||||
for cmd in rhino "rhino -require" narwhal ringo phantomjs; do
|
||||
echo ""
|
||||
echo "Running performance suite in $cmd..."
|
||||
$cmd perf.js ../dist/lodash.compat.js && $cmd perf.js ../dist/lodash.compat.min.js
|
||||
|
||||
Reference in New Issue
Block a user