Skip to content

Commit 2de5004

Browse files
committed
add a simple benchmark
1 parent d234839 commit 2de5004

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

bench.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
var tinyQueue = require('./');
4+
5+
var N = 1000000;
6+
7+
var data = [];
8+
for (var i = 0; i < N; i++) data[i] = {value: Math.random()};
9+
10+
var q = tinyQueue(null, compare);
11+
12+
function compare(a, b) {
13+
return a.value - b.value;
14+
}
15+
16+
console.time('push ' + N);
17+
for (i = 0; i < 1000000; i++) q.push(data[i]);
18+
console.timeEnd('push ' + N);
19+
20+
console.time('pop ' + N);
21+
for (i = 0; i < 1000000; i++) q.pop();
22+
console.timeEnd('pop ' + N);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "The smallest and simplest JavaScript priority queue",
55
"main": "index.js",
66
"scripts": {
7-
"test": "eslint index.js test.js && tape test.js"
7+
"test": "eslint index.js test.js bench.js && tape test.js"
88
},
99
"repository": {
1010
"type": "git",

0 commit comments

Comments
 (0)