Benchmark Math.floor (v3)

Revision 3 of this benchmark created on


Description

Find a faster way to run the Math.floor function.

Preparation HTML

<script>
  var floor = Math.floor;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor(n)
var n0 = Math.floor(0.12341234);
var n1 = Math.floor(0.2);
var n2 = Math.floor(-3.1234);
var n3 = Math.floor(100000.23);
var n4 = Math.floor(2.12341234123412341324);
var n5 = Math.floor(100.0000000000000000001);
ready
~~n
var n0 = ~~0.12341234;
var n1 = ~~0.2;
var n2 = ~~ - 3.1234;
var n3 = ~~100000.23;
var n4 = ~~2.12341234123412341324;
var n5 = ~~100.0000000000000000001;
ready
n|n
var n0 = 0.12341234 | 0.12341234;
var n1 = 0.2 | 0.2;
var n2 = -3.1234 | -3.1234;
var n3 = 100000.23 | 100000.23;
var n4 = 2.12341234123412341324 | 2.12341234123412341324;
var n5 = 100.0000000000000000001 | 100.0000000000000000001;
ready
n&n
var n0 = 0.12341234 & 0.12341234;
var n1 = 0.2 & 0.2;
var n2 = -3.1234 & -3.1234;
var n3 = 100000.23 & 100000.23;
var n4 = 2.12341234123412341324 & 2.12341234123412341324;
var n5 = 100.0000000000000000001 & 100.0000000000000000001;
ready
n << 0
var n0 = 0.12341234 << 0;
var n1 = 0.2 << 0;
var n2 = -3.1234 << 0;
var n3 = 100000.23 << 0;
var n4 = 2.12341234123412341324 << 0;
var n5 = 100.0000000000000000001 << 0;
ready
floor(n)
var n0 = floor(0.12341234);
var n1 = floor(0.2);
var n2 = floor(-3.1234);
var n3 = floor(100000.23);
var n4 = floor(2.12341234123412341324);
var n5 = floor(100.0000000000000000001);
ready
0|
var n0 = 0|0.12341234;
var n1 = 0|0.2;
var n2 = 0|-3.1234;
var n3 = 0|100000.23;
var n4 = 0|2.12341234123412341324;
var n5 = 0|100.0000000000000000001;
ready

Revisions

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

  • Revision 1: published by Daniel Lamb on
  • Revision 2: published by WebReflection on
  • Revision 3: published on