Division vs right shift

Benchmark created on


Setup

const a = [];

for (let i = 0; i < 100000; i++) {
	a[i] = i * 4;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Division
for (let i = 0; i < 100000; i++) {
	a[i] = a[i] / 4;
}
ready
Shift
for (let i = 0; i < 100000; i++) {
	a[i] = a[i] >> 2;
}
ready

Revisions

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