Math.ceil (v3)

Revision 3 of this benchmark created by Paul H Howells on


Preparation HTML

<script>
  function ceil(n) {
   if (~~n === n) return n;
   return n + 1 | 0;
  }
  cacheCeil = Math.ceil;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Math.ceil
var n = Math.ceil(4.241);
ready
ceil
var n = ceil(4.241);
ready
cached
var n = cacheCeil(4.241);
ready
inline
var n = (4.241 === ~~4.241) ? 4.241 : 4.241 + 1 | 0;
ready
inline ~~
var n = (4.241 === ~~4.241) ? 4.241 : ~~4.241 + 1;
ready

Revisions

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

  • Revision 3: published by Paul H Howells on