Skip to content

Commit

Permalink
Merge pull request jashkenas#1221 from liuyl/speedjs
Browse files Browse the repository at this point in the history
add big objects to speed.js
  • Loading branch information
jashkenas committed Jul 23, 2013
2 parents 717b6e6 + 3473186 commit cbed8a7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/speed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

var numbers = [];
for (var i=0; i<1000; i++) numbers.push(i);
var objects = _.map(numbers, function(n){ return {num : n}; });
var objArray = _.map(numbers, function(n){ return {num : n}; });
var bigObj = {};
_.times(1000, function(n){ bigObj['key' + n] = n; });
var randomized = _.sortBy(numbers, function(){ return Math.random(); });
var deep = _.map(_.range(100), function() { return _.range(1000); });

Expand All @@ -25,15 +27,15 @@
});

JSLitmus.test('_.map()', function() {
return _.map(objects, function(obj){ return obj.num; });
return _.map(objArray, function(obj){ return obj.num; });
});

JSLitmus.test('jQuery.map()', function() {
return jQuery.map(objects, function(obj){ return obj.num; });
return jQuery.map(objArray, function(obj){ return obj.num; });
});

JSLitmus.test('_.pluck()', function() {
return _.pluck(objects, 'num');
return _.pluck(objArray, 'num');
});

JSLitmus.test('_.uniq()', function() {
Expand All @@ -53,11 +55,11 @@
});

JSLitmus.test('_.keys()', function() {
return _.keys(objects);
return _.keys(bigObj);
});

JSLitmus.test('_.values()', function() {
return _.values(objects);
return _.values(bigObj);
});

JSLitmus.test('_.intersection()', function() {
Expand Down

0 comments on commit cbed8a7

Please sign in to comment.