Math.ceil and Math.floor replacement (v6)

Revision 6 of this benchmark created by carlo on


Preparation HTML

<script>
  var x = 10,
      y = 7;
  
  
  var _ceil = function(n) {
   var f = (n << 0),
       f = f == n ? f : f + 1;
   return f;
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor
Math.floor(x / y);
ready
Math.floor with parseInt
parseInt(x / y);
ready
Math.floor with bitwise or
(x / y) | 0;
ready
Math.ceil
Math.ceil(x / y);
ready
Math.ceil with parseInt
parseInt((x / y) + 1);
ready
Math.ceil with bitwise or ()
((x / y) + 1 | 0);
ready
custom _ceil
_ceil(x / y)
ready

Revisions

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