Permalink
Browse files

the benchmark

  • Loading branch information...
isaacs committed Nov 22, 2011
1 parent b280846 commit 3de29d7602897bba0a51f590025c772666229e93
Showing with 55 additions and 0 deletions.
  1. +55 −0 bench.js
View
@@ -0,0 +1,55 @@
var bench = require("bench")
var l = 1000
, FastList = require("./fast-list.js")
exports.countPerLap = l * 2
exports.compare =
{ "[]": function () {
var list = []
for (var j = 0; j < l; j ++) {
if (j % 2) list.push(j)
else list.unshift(j)
}
for (var j = 0; j < l; j ++) {
if (j % 2) list.shift(j)
else list.pop(j)
}
}
, "new Array()": function () {
var list = new Array()
for (var j = 0; j < l; j ++) {
if (j % 2) list.push(j)
else list.unshift(j)
}
for (var j = 0; j < l; j ++) {
if (j % 2) list.shift(j)
else list.pop(j)
}
}
// , "FastList()": function () {
// var list = FastList()
// for (var j = 0; j < l; j ++) {
// if (j % 2) list.push(j)
// else list.unshift(j)
// }
// for (var j = 0; j < l; j ++) {
// if (j % 2) list.shift(j)
// else list.pop(j)
// }
// }
, "new FastList()": function () {
var list = new FastList()
for (var j = 0; j < l; j ++) {
if (j % 2) list.push(j)
else list.unshift(j)
}
for (var j = 0; j < l; j ++) {
if (j % 2) list.shift(j)
else list.pop(j)
}
}
}
bench.runMain()

0 comments on commit 3de29d7

Please sign in to comment.