bitwise left and right shifts vs multiply and divide

Benchmark created by inimino on


Description

Comparing bit shifts with equivalent multiplication and division by 2.

Preparation HTML

<script>
  var x, y, z, i;
  
  x = 1
  y = 42
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
<< 1
for (i = 10000; --i;) z = x << 1
ready
* 2
for (i = 10000; --i;) z = x * 2
ready
>> 1
for (i = 10000; --i;) z = y >> 1
ready
/2
for (i = 10000; --i;) z = y / 2
ready

Revisions

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

  • Revision 1: published by inimino on