go-condi

Benchmark created by Andreas Deuschlinger on


Setup

var lookup = [0,1,2,3,4,5,6,7,8,9];

Test runner

Ready to run.

Testing in
TestOps/sec
if
var rn=Math.floor(Math.random()*11);

if( rn == 0 ){0
}else if( rn == 1 ){1
}else if( rn == 2 ){2
}else if( rn == 3 ){3
}else if( rn == 4 ){4
}else if( rn == 5 ){5
}else if( rn == 6 ){6
}else if( rn == 7 ){7
}else if( rn == 8 ){8
}else if( rn == 9 ){9
}else{rn
}
ready
switch
var rn=Math.floor(Math.random()*11);

switch( rn ) {
case 0:0
break;
case 1:1
break;
case 2:2
break;
case 3:3
break;
case 4:4
break;
case 5:5
break;
case 6:6
break;
case 7:7
break;
case 8:8
break;
case 9:9
break;
default:rn
break;
}
ready
lookup
var rn=Math.floor(Math.random()*11);

lookup[rn];
ready
lookup local
var lookup = [0,1,2,3,4,5,6,7,8,9];
var rn=Math.floor(Math.random()*11);

lookup[rn];
ready

Revisions

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

  • Revision 1: published by Andreas Deuschlinger on