Stack VS Array

JavaScript performance comparison

Test case created by Mo Wang

Preparation code

<script src="https://raw.github.com/marty-wang/Algorithms/master/src/compiled/basics.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
   
   
   
   
   
};
</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
iterate stack
var stack = new Alg.Stack();
stack.push("hallo world-0");
stack.push("hallo world-1");
stack.push("hallo world-2");
stack.push("hallo world-0");
stack.push("hallo world-1");
stack.push("hallo world-2");
stack.push("hallo world-0");
stack.push("hallo world-1");
stack.push("hallo world-2");
stack.push("hallo world-0");
stack.push("hallo world-1");
stack.push("hallo world-2");
stack.push("hallo world-0");
stack.push("hallo world-1");
stack.push("hallo world-2");
stack.push("hallo world-0");
stack.push("hallo world-1");
stack.push("hallo world-2");

var iterator = stack.iterator();
while(iterator.hasNext()) {
  var item = iterator.next();
}
pending…
iterate array
var array = [];
array.push("hallo world-0");
array.push("hallo world-1");
array.push("hallo world-2");
array.push("hallo world-0");
array.push("hallo world-1");
array.push("hallo world-2");
array.push("hallo world-0");
array.push("hallo world-1");
array.push("hallo world-2");
array.push("hallo world-0");
array.push("hallo world-1");
array.push("hallo world-2");
array.push("hallo world-0");
array.push("hallo world-1");
array.push("hallo world-2");
array.push("hallo world-0");
array.push("hallo world-1");
array.push("hallo world-2");

var steps = array.length;
while(steps--) {
  var item = array[steps];
}
pending…
iterate queue
var queue = new Alg.Queue();
queue.enqueue("hallo world-0");
queue.enqueue("hallo world-1");
queue.enqueue("hallo world-2");
queue.enqueue("hallo world-0");
queue.enqueue("hallo world-1");
queue.enqueue("hallo world-2");
queue.enqueue("hallo world-0");
queue.enqueue("hallo world-1");
queue.enqueue("hallo world-2");
queue.enqueue("hallo world-0");
queue.enqueue("hallo world-1");
queue.enqueue("hallo world-2");
queue.enqueue("hallo world-0");
queue.enqueue("hallo world-1");
queue.enqueue("hallo world-2");
queue.enqueue("hallo world-0");
queue.enqueue("hallo world-1");
queue.enqueue("hallo world-2");

var iterator = queue.iterator();
while(iterator.hasNext()) {
  var item = iterator.next();
}
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment