Cleanup test.js and perf.js and add _(array) benchmark.

Former-commit-id: bcd120c9ee332db39c7b637894751f2861bac069
This commit is contained in:
John-David Dalton
2013-03-09 18:15:32 -08:00
parent cbf20b3271
commit 31e4e631f9
4 changed files with 36 additions and 40 deletions

View File

@@ -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>

View File

@@ -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, '\

View File

@@ -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

View File

@@ -43,19 +43,17 @@
}());
/** The `lodash` function to test */
var _ =
window._ || (
_ = load(filePath) || window._,
_ = _._ || _,
_.runInContext(window)
);
var _ = window._ || (window._ = (
_ = load(filePath) || window._,
_ = _._ || _,
_.runInContext(window)
));
/** The `platform` object to check */
var platform = (
window.platform ||
var platform = window.platform || (window.platform = (
load('../vendor/platform.js/platform.js') ||
window.platform
);
));
/** Used to pass falsey values to methods */
var falsey = [