Cleanup benchmarks in perf.js.

Former-commit-id: f845855383e01c63d513cea53cec86abb4f4fb65
This commit is contained in:
John-David Dalton
2012-08-25 20:13:24 -07:00
parent 0e4afefc7f
commit 7adf5e763b
3 changed files with 5 additions and 71 deletions

View File

@@ -308,24 +308,6 @@
}\
}\
}\
if (typeof omit != "undefined") {\
\
var tenWordObject = {\
"one": 1,\
"two": 2,\
"three": 3,\
"four": 4,\
"five": 5,\
"six": 6,\
"seven": 7,\
"eight": 8,\
"nine": 9,\
"ten": 10\
};\
\
var _omitted = _.omit(wordToNumber, tenWordObject),\
lodashOmitted = lodash.omit(wordToNumber, tenWordObject);\
}\
\
if (typeof template != "undefined") {\
var tplData = {\
@@ -1120,18 +1102,6 @@
})
);
suites.push(
Benchmark.Suite('`_.omit` iterating 10 properties, omitting 20 keys')
.add('Lo-Dash', {
'fn': 'lodash.omit(tenWordObject, words)',
'teardown': 'function omit(){}'
})
.add('Underscore', {
'fn': '_.omit(tenWordObject, words)',
'teardown': 'function omit(){}'
})
);
/*--------------------------------------------------------------------------*/
suites.push(
@@ -1378,42 +1348,6 @@
)
);
suites.push(
Benchmark.Suite('`_.union` iterating an array of 25 elements')
.add('Lo-Dash', {
'fn': 'lodash.union(twentyFiveValues, twentyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': '_.union(twentyFiveValues, twentyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.union` iterating an array of 50 elements')
.add('Lo-Dash', {
'fn': 'lodash.union(fiftyValues, fiftyValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': '_.union(fiftyValues, fiftyValues2)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.union` iterating an array of 75 elements')
.add('Lo-Dash', {
'fn': 'lodash.union(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': '_.union(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
);
/*--------------------------------------------------------------------------*/
suites.push(

View File

@@ -20,7 +20,7 @@ if(G&&a.lastIndexOf===G)return a.lastIndexOf(c);for(var b=a.length;b--;)if(a[b]=
K.prototype=a.prototype;var b=new K,g=a.apply(b,e.concat(h.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=h.call(arguments,1);c.length==0&&(c=b.functions(a));i(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=h.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,
[a,1].concat(h.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,j,h,i=b.debounce(function(){j=g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;j&&a.apply(d,e);i()},c));if(g)j=true;else{g=true;h=a.apply(d,e)}i();return h}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments,h=d&&!e;clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b);h&&a.apply(f,g)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;
return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(h.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=P||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=
function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){i(h.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={},d=b.flatten(h.call(arguments,1));i(d,function(b){b in a&&(c[b]=a[b])});return c};b.omit=function(a){var c=b.extend({},a),d=b.flatten(h.call(arguments,1));i(d,function(a){delete c[a]});return c};b.defaults=function(a){i(h.call(arguments,1),
function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){i(h.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={},d=b.flatten(h.call(arguments,1));i(d,function(b){b in a&&(c[b]=a[b])});return c};b.omit=function(a){var c={},d=b.flatten(h.call(arguments,1)),e;for(e in a)b.include(d,e)||(c[e]=a[e]);return c};b.defaults=function(a){i(h.call(arguments,1),
function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};var u=function(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=m.call(a);if(e!=m.call(c))return false;switch(e){case "[object String]":return a==
""+c;case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){f=a.length;if(g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&u(a[f],c[f],d)))break}else{if("constructor"in
a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)){f++;if(!(g=b.has(c,h)&&u(a[h],c[h],d)))break}if(g){for(h in c)if(b.has(c,h)&&!f--)break;g=!f}}d.pop();return g};b.isEqual=function(a,b){return u(a,b,[])};b.isEmpty=function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return m.call(a)=="[object Array]"};

View File

@@ -708,11 +708,11 @@
// Return a copy of the object without the blacklisted properties.
_.omit = function(obj) {
var copy = _.extend({}, obj);
var copy = {};
var keys = _.flatten(slice.call(arguments, 1));
each(keys, function(key) {
delete copy[key];
});
for (var key in obj) {
if (!_.include(keys, key)) copy[key] = obj[key];
}
return copy;
};