Or vs Floor (v17)

Revision 17 of this benchmark created by Peter Gao on


Preparation HTML

<script>
  var i = 100000;
  var array = [];
  while ( i-- ) {
      array[ i ] = Math.random() * 100;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Floor
var i = 100000, floor=Math.floor;
var sum = 0;
var b = 0;
while ( i-- ) {
    sum += floor( array[ i ] );
}
b = sum - i;
ready
OR
var i = 100000;
var sum = 0;
var b = 0;
while ( i-- ) {
    sum += array[ i ] | 0;
}
b = sum - i;
ready

Revisions

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