type-inference-performance

JavaScript performance comparison

Test case created by DrSlump

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var array_of_ints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    var array_of_mixed = [1, '2', '3', 4, 5, '6', '7', '8', 9, '10']
};
</script>

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 of ints
var sum = 0
for (var i=0; i<array_of_ints.length; i++) {
  sum += array_of_ints[i];
}
pending…
array of mixed
var sum = 0
for (var i=0; i<array_of_mixed.length; i++) {
  sum += array_of_mixed[i];
}
pending…
fixed type
var a, b;
for (var i=0; i<100; i++) {
  a = 0;
  a += 1;
  b = 'foo';
  b += 'bar';
}
pending…
mixed type
var a;
for (var i=0; i<100; i++) {
  a = 0;
  a += 1;
  a = 'foo';
  a += 'bar';
}
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