native vs typed js array speed

JavaScript performance comparison

Revision 89 of this test case created by pusha

Preparation code

<script>
  var ARRAY_SIZE = 991;
  var DELTA = 67;
  var COUNT = 10000;
  
  var arr = new Array(ARRAY_SIZE);
  var f64 = new Float64Array(ARRAY_SIZE);

!(function(){
  var x;
  for (var i = 0; i < ARRAY_SIZE; ++i) {
    x = Math.random();
    arr[i] = x;
    f64[i] = x;
  }
}());

  function sumArr() {
    var s = 0;
    for (var i = 0; i < COUNT; ++i) {
      s += arr[i * DELTA % ARRAY_SIZE];
    }
    return s;
  }

  function sumF64() {
    var s = 0;
    for (var i = 0; i < COUNT; ++i) {
      s += f64[i * DELTA % ARRAY_SIZE];
    }
    return s;
  }
</script>
    

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Native
sumArr();
pending…
Float64
sumF64();
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.

0 Comments