floor(x/16) vs x&$ff0

Benchmark created on


Preparation HTML

<script>
var foo=64;
var bar=68;
var hey=68.5;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
floor(x/16)
for (var i = 0, j = 100000; i < j; i += 1) {
 result = 16*Math.floor(foo/16);
 result = 16*Math.floor(bar/16);
 result = 16*Math.floor(hey/16);
}
ready
~~(x/16)
for (var i = 0, j = 100000; i < j; i += 1) {
 result = 16*(~~(foo/16));
 result = 16*(~~(bar/16));
 result = 16*(~~(hey/16));
}
ready
x&$ff0
for (var i = 0, j = 100000; i < j; i += 1) {
 result = foo&0xff0;
 result = bar&0xff0;
 result = hey&0xff0;
}
ready

Revisions

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