Queue array

JavaScript performance comparison

Test case created by Epeli

Info

http://safalra.com/web-design/javascript/queues/ http://safalra.com/web-design/javascript/queues/Queue.js

Preparation code

<script src="http://safalra.com/web-design/javascript/queues/Queue.js"></script>
<script>
  var a = [];
  var q = new Queue();
 
  for (i = 0; i <= 10000; i++) {
   a.push(i);
  }
 
  var i;
  for (i = 0; i <= 10000; i++) {
   q.enqueue(i);
  }
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
array
var i;

for (i = 0; i <= 100000; i++) {
 a.shift();
 a.push(i);
}
pending…
queue
var i;

for (i = 0; i <= 100000; i++) {
 q.dequeue();
 q.enqueue(i);
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment