Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

Commit

Permalink
the benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Nov 22, 2011
1 parent b280846 commit 3de29d7
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions bench.js
@@ -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.