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> <body>
<div id="perf-toolbar"></div> <div id="perf-toolbar"></div>
<script src="../vendor/platform.js/platform.js"></script> <script src="../vendor/platform.js/platform.js"></script>
<script src="../lodash.js"></script>
<script src="../vendor/benchmark.js/benchmark.js"></script> <script src="../vendor/benchmark.js/benchmark.js"></script>
<script src="../vendor/firebug-lite/src/firebug-lite-debug.js"></script> <script src="../vendor/firebug-lite/src/firebug-lite-debug.js"></script>
<script src="perf-ui.js"></script> <script src="perf-ui.js"></script>

View File

@@ -25,27 +25,25 @@
return result; return result;
}()); }());
/** Load Benchmark.js */
var Benchmark =
window.Benchmark || (
Benchmark = load('../vendor/benchmark.js/benchmark.js') || window.Benchmark,
Benchmark.Benchmark || Benchmark
);
/** Load Lo-Dash */ /** Load Lo-Dash */
var lodash = var lodash = window.lodash || (window.lodash = (
window.lodash || ( lodash = load(filePath) || window._,
lodash = load(filePath) || window._, lodash = lodash._ || lodash,
lodash = lodash._ || lodash, lodash.noConflict()
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 */ /** Load Underscore */
var _ = var _ = window._ || (window._ = (
window._ || ( _ = load('../vendor/underscore/underscore.js') || window._,
_ = load('../vendor/underscore/underscore.js') || window._, _._ || _
_._ || _ ));
);
/** Used to access the Firebug Lite panel (set by `run`) */ /** Used to access the Firebug Lite panel (set by `run`) */
var fbPanel; var fbPanel;
@@ -68,16 +66,6 @@
/** The other library basename */ /** The other library basename */
var otherName = basename(ui.otherPath, '.js'); 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, { lodash.extend(Benchmark.options, {
'async': true, 'async': true,
'setup': '\ 'setup': '\
var window = Function("return this || global")(),\ var _ = window._,\
_ = window._,\
lodash = window.lodash,\ lodash = window.lodash,\
belt = this.name == "Lo-Dash" ? 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( suites.push(
Benchmark.Suite('`_(...)` with an object') Benchmark.Suite('`_(...)` with an object')
.add(buildName, '\ .add(buildName, '\

View File

@@ -3,7 +3,7 @@ cd "$(dirname "$0")"
echo "Running performance suite in node..." echo "Running performance suite in node..."
node perf.js ../dist/lodash.js && node perf.js ../dist/lodash.min.js 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 ""
echo "Running performance suite in $cmd..." echo "Running performance suite in $cmd..."
$cmd perf.js ../dist/lodash.compat.js && $cmd perf.js ../dist/lodash.compat.min.js $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 */ /** The `lodash` function to test */
var _ = var _ = window._ || (window._ = (
window._ || ( _ = load(filePath) || window._,
_ = load(filePath) || window._, _ = _._ || _,
_ = _._ || _, _.runInContext(window)
_.runInContext(window) ));
);
/** The `platform` object to check */ /** The `platform` object to check */
var platform = ( var platform = window.platform || (window.platform = (
window.platform ||
load('../vendor/platform.js/platform.js') || load('../vendor/platform.js/platform.js') ||
window.platform window.platform
); ));
/** Used to pass falsey values to methods */ /** Used to pass falsey values to methods */
var falsey = [ var falsey = [