collection.js
This file
Path
benchmarks/collection.js
107 lines · 1.9 KiB · JavaScript
Last changed by
Faster benchmarksvisionmediabefore adoptiondc4c542
History of this fileTake it
Started Collection benchmarksvisionmediabefore adoptiondba488d
lines 1–17why, one step back12require.paths.unshift('lib')3require.paths.unshift('benchmarks')4process.mixin(GLOBAL, require('sys'))5process.mixin(GLOBAL, require('benchmark'))6require('express')78print = puts910range = function(a, b) {11 var array = []12 while (a++ < b)13 array.push(a-1)14 return array15}1617suite('Collection with array', 100, function(){Faster benchmarksvisionmediabefore adoptiondc4c542
line 18why, one step back18 array = range(0, 10000)Started Collection benchmarksvisionmediabefore adoptiondba488d
lines 19–34why, one step back19 20 benchmark('for', function(){21 for (var i = 0, len = array.length; i < len; ++i) ;22 })23 24 benchmark('for uncached', function(){25 for (var i = 0; i < array.length; ++i) ;26 })27 28 benchmark('forEach', function(){29 array.forEach(function(){})30 })31 32 benchmark('#each', function(){33 $(array).each(function(){})34 })Added most the benchmarks for Collectionvisionmediabefore adoption2d87bec
lines 35–106why, one step back35 36 benchmark('#map', function(){37 $(array).map(function(n){ return ++n })38 })39 40 benchmark('#find', function(){41 $(array).find(function(n){ return n > 5000 })42 })43 44 benchmark('#select', function(){45 $(array).select(function(n){ return n % 2 })46 })47 48 benchmark('#first', function(){49 $(array).first(5000)50 })51 52 benchmark('#slice', function(){53 $(array).slice(100, 5000)54 })55 56 benchmark('#drop', function(){57 $(array).drop(5000)58 })59 60 benchmark('#length', function(){61 $(array).length()62 })63 64 benchmark('#keys', function(){65 $(array).keys()66 })67 68 benchmark('#toArray()', function(){69 $(array).toArray()70 })71 72 benchmark('#min', function(){73 $(array).min()74 })75 76 benchmark('#max', function(){77 $(array).max()78 })79 80 benchmark('#sum', function(){81 $(array).sum()82 })83 84 benchmark('#avg', function(){85 $(array).avg()86 })87 88 benchmark('#clone', function(){89 $(array).clone()90 })91 92 benchmark('#merge', function(){93 $(array).merge({ foo: 'bar' })94 })95 96 benchmark('#sample', function(){97 $(array).sample()98 })99 100 benchmark('#chunk', function(){101 $(array).chunk(5)102 })103 104 benchmark('#at', function(){105 $(array).at(5000)106 })Started Collection benchmarksvisionmediabefore adoptiondba488d
line 107why, one step back107})