Number flooring (v7)

Revision 7 of this benchmark created on


Preparation HTML

<script>
  var foo = 5.98897982734987897234234;
  var bar = 2.9834988349834;
  var qux = 9.34872734;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
parseInt
var result;
for (var i = 0, j = 100000; i < j; ++i) {
 result = parseInt(foo, 10);
 result = parseInt(bar, 10);
 result = parseInt(qux, 10);
}
ready
~~
var result;
for (var i = 0, j = 100000; i < j; ++i) {
 result = ~~ (foo);
 result = ~~ (bar);
 result = ~~ (qux);
}
ready
Math.floor
var result;
for (var i = 0, j = 100000; i < j; ++i) {
 result = Math.floor(foo);
 result = Math.floor(bar);
 result = Math.floor(qux);
}
ready
toFixed (equiv to round)
var result;
for (var i = 0, j = 100000; i < j; ++i) {
 result = foo.toFixed();
 result = bar.toFixed();
 result = qux.toFixed();
}
ready
>>
var result;
for (var i = 0, j = 100000; i < j; ++i) {
 result = foo >> 0;
 result = bar >> 0;
 result = qux >> 0;
}
ready
Math.round
var result;
for (var i = 0, j = 100000; i < j; ++i) {
 result = Math.round(foo);
 result = Math.round(bar);
 result = Math.round(qux);
}
ready
<<
var result;
for (var i = 0, j = 100000; i < j; ++i) {
 result = foo << 0;
 result = bar << 0;
 result = qux << 0;
}
ready

Revisions

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