dereference bencmark

JavaScript performance comparison

Test case created by Oleksandr Nikitin

Preparation code

<script>
var ints1 = [];
var ints2 = [];
var ints3 = [];

for (var i = 0; i < 1024 * 1024; i++) {
  ints1.push(Math.floor(Math.random() * (ints1.length + 1)));
}
for (var i = 0; i < 1024 * 1024 * 10; i++) {
  ints2.push(Math.floor(Math.random() * (ints2.length + 1)));
}
for (var i = 0; i < 1024 * 1024 * 50; i++) {
  ints3.push(Math.floor(Math.random() * (ints3.length + 1)));
}

</script>
<script>
Benchmark.prototype.setup = function() {
    var icur = 0;
   
    // http://stackoverflow.com/questions/962802#962890
   
    //    current = Math.floor(Math.random() * (top + 1));
};
</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
random walk 100k*001
icurs=[];
for(var attempt=0;attempt<100;attempt++){
icur = Math.floor(Math.random() * (ints1.length + 1));
for (var i = 0; i < 1024 * 102; i++) {
  icur = ints1[icur];
}
icurs.push(icur);
}
console.log(icurs[5]);
 
pending…
random walk 100k*010
icurs=[];
for(var attempt=0;attempt<100;attempt++){
icur = Math.floor(Math.random() * (ints2.length + 1));
for (var i = 0; i < 1024 * 102; i++) {
  icur = ints2[icur];
}
icurs.push(icur);
}
console.log(icurs[5]);
 
pending…
random walk 100k*050
icurs=[];
for(var attempt=0;attempt<100;attempt++){
icur = Math.floor(Math.random() * (ints3.length + 1));
for (var i = 0; i < 1024 * 102; i++) {
  icur = ints3[icur];
}
icurs.push(icur);
}
console.log(icurs[5]);
 
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