Bitshifting vs division by 2 (v2)

Revision 2 of this benchmark created on


Setup

const iterations = 100000000
let result = 0
let i = 0

Test runner

Ready to run.

Testing in
TestOps/sec
division by 2
for (i = 0; i < iterations; i++) {
	result = 10 / 2
}
ready
bitshift
for (i = 0; i < iterations; i++) {
	result = 10 >> 1
}
ready
divide float
for (i = 0; i < iterations; i++) {
	result = 10.19385 / 2
}
ready
bitshift float
for (i = 0; i < iterations; i++) {
	result = 10.19385 >> 1
}
ready
multiply by 0.5
for (i = 0; i < iterations; i++) {
	result = 10 * 0.5
}
ready
multiply float by 0.5
for (i = 0; i < iterations; i++) {
	result = 10.19385 * 0.5
}
ready

Revisions

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