mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
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()
|
|
|