mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Make pref.js work in Rhino, Narwhal, and Ringo again.
Former-commit-id: 1969153262cbc3ac134018aa021de92a86d6d7ef
This commit is contained in:
63
perf/perf.js
63
perf/perf.js
@@ -14,7 +14,7 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
var last = result[result.length - 1];
|
var last = result[result.length - 1];
|
||||||
result = (result.length > min && !/test(?:\.js)?$/.test(last))
|
result = (result.length > min && !/perf(?:\.js)?$/.test(last))
|
||||||
? last
|
? last
|
||||||
: '../lodash.js';
|
: '../lodash.js';
|
||||||
|
|
||||||
@@ -54,6 +54,9 @@
|
|||||||
/** Used to queue benchmark suites */
|
/** Used to queue benchmark suites */
|
||||||
var suites = [];
|
var suites = [];
|
||||||
|
|
||||||
|
/** Used to resolve a value's internal [[Class]] */
|
||||||
|
var toString = Object.prototype.toString;
|
||||||
|
|
||||||
/** The `ui` object */
|
/** The `ui` object */
|
||||||
var ui = window.ui || ({
|
var ui = window.ui || ({
|
||||||
'buildPath': basename(filePath, '.js'),
|
'buildPath': basename(filePath, '.js'),
|
||||||
@@ -66,6 +69,15 @@
|
|||||||
/** The other library basename */
|
/** The other library basename */
|
||||||
var otherName = basename(ui.otherPath, '.js');
|
var otherName = basename(ui.otherPath, '.js');
|
||||||
|
|
||||||
|
/** Detect if in a browser environment */
|
||||||
|
var isBrowser = !!(window.document && window.navigator);
|
||||||
|
|
||||||
|
/** Detect Java environment */
|
||||||
|
var isJava = !isBrowser && /Java/.test(toString.call(window.java));
|
||||||
|
|
||||||
|
/** Add `console.log()` support for Narwhal, Rhino, and RingoJS */
|
||||||
|
var console = window.console || (window.console = { 'log': window.print });
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +134,7 @@
|
|||||||
fbPanel.getElementById('fbPanel1');
|
fbPanel.getElementById('fbPanel1');
|
||||||
|
|
||||||
log('\nSit back and relax, this may take a while.');
|
log('\nSit back and relax, this may take a while.');
|
||||||
suites[0].run();
|
suites[0].run({ 'async': !isJava });
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -165,7 +177,7 @@
|
|||||||
|
|
||||||
if (suites.length) {
|
if (suites.length) {
|
||||||
// run next suite
|
// run next suite
|
||||||
suites[0].run();
|
suites[0].run({ 'async': !isJava });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var fastestTotalHz = Math.max(score.a, score.b),
|
var fastestTotalHz = Math.max(score.a, score.b),
|
||||||
@@ -443,6 +455,9 @@
|
|||||||
\
|
\
|
||||||
var _tpl = _.template(tpl),\
|
var _tpl = _.template(tpl),\
|
||||||
_tplVerbose = _.template(tplVerbose, null, settingsObject);\
|
_tplVerbose = _.template(tplVerbose, null, settingsObject);\
|
||||||
|
}\
|
||||||
|
if (typeof where != "undefined") {\
|
||||||
|
var whereObject = { "num": 9 };\
|
||||||
}'
|
}'
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -478,7 +493,8 @@
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
suites.push(
|
// avoid Underscore induced `OutOfMemoryError` in Rhino, Narwhal, and Ringo
|
||||||
|
!isJava && suites.push(
|
||||||
Benchmark.Suite('`_(...).tap(...)`')
|
Benchmark.Suite('`_(...).tap(...)`')
|
||||||
.add(buildName, {
|
.add(buildName, {
|
||||||
'fn': 'lodashChaining.tap(lodash.identity)',
|
'fn': 'lodashChaining.tap(lodash.identity)',
|
||||||
@@ -876,14 +892,17 @@
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
suites.push(
|
// avoid Underscore induced `OutOfMemoryError` in Rhino, Narwhal, and Ringo
|
||||||
|
!isJava && suites.push(
|
||||||
Benchmark.Suite('`_.find` with `properties`')
|
Benchmark.Suite('`_.find` with `properties`')
|
||||||
.add(buildName, '\
|
.add(buildName, {
|
||||||
lodash.find(objects, { "num": 9 });'
|
'fn': 'lodash.find(objects, whereObject)',
|
||||||
)
|
'teardown': 'function where(){}'
|
||||||
.add(otherName, '\
|
})
|
||||||
_.findWhere(objects, { "num": 9 });'
|
.add(otherName, {
|
||||||
)
|
'fn': '_.findWhere(objects, whereObject)',
|
||||||
|
'teardown': 'function where(){}'
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -1328,13 +1347,13 @@
|
|||||||
Benchmark.Suite('`_.reduce` iterating an object')
|
Benchmark.Suite('`_.reduce` iterating an object')
|
||||||
.add(buildName, '\
|
.add(buildName, '\
|
||||||
lodash.reduce(object, function(result, value, key) {\
|
lodash.reduce(object, function(result, value, key) {\
|
||||||
result.push([key, value]);\
|
result.push(key, value);\
|
||||||
return result;\
|
return result;\
|
||||||
}, []);'
|
}, []);'
|
||||||
)
|
)
|
||||||
.add(otherName, '\
|
.add(otherName, '\
|
||||||
_.reduce(object, function(result, value, key) {\
|
_.reduce(object, function(result, value, key) {\
|
||||||
result.push([key, value]);\
|
result.push(key, value);\
|
||||||
return result;\
|
return result;\
|
||||||
}, []);'
|
}, []);'
|
||||||
)
|
)
|
||||||
@@ -1362,13 +1381,13 @@
|
|||||||
Benchmark.Suite('`_.reduceRight` iterating an object')
|
Benchmark.Suite('`_.reduceRight` iterating an object')
|
||||||
.add(buildName, '\
|
.add(buildName, '\
|
||||||
lodash.reduceRight(object, function(result, value, key) {\
|
lodash.reduceRight(object, function(result, value, key) {\
|
||||||
result.push([key, value]);\
|
result.push(key, value);\
|
||||||
return result;\
|
return result;\
|
||||||
}, []);'
|
}, []);'
|
||||||
)
|
)
|
||||||
.add(otherName, '\
|
.add(otherName, '\
|
||||||
_.reduceRight(object, function(result, value, key) {\
|
_.reduceRight(object, function(result, value, key) {\
|
||||||
result.push([key, value]);\
|
result.push(key, value);\
|
||||||
return result;\
|
return result;\
|
||||||
}, []);'
|
}, []);'
|
||||||
)
|
)
|
||||||
@@ -1714,12 +1733,14 @@
|
|||||||
|
|
||||||
suites.push(
|
suites.push(
|
||||||
Benchmark.Suite('`_.where`')
|
Benchmark.Suite('`_.where`')
|
||||||
.add(buildName, '\
|
.add(buildName, {
|
||||||
lodash.where(objects, { "num": 9 });'
|
'fn': 'lodash.where(objects, whereObject);',
|
||||||
)
|
'teardown': 'function where(){}'
|
||||||
.add(otherName, '\
|
})
|
||||||
_.where(objects, { "num": 9 });'
|
.add(otherName, {
|
||||||
)
|
'fn': '_.where(objects, whereObject);',
|
||||||
|
'teardown': 'function where(){}'
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user