Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
div by 2 vs shift 1 vs mul 0.5
(version: 1)
Comparing performance of:
Division (/ 2) vs Bitwise Shift (>> 1) vs Multiplication (* 0.5)
Created:
one year ago
by:
Registered User
Jump to the latest result
Tests:
Division (/ 2)
function testDivision(iterations) { let x = 123456; console.time('Division (/ 2)'); for (let i = 0; i < iterations; i++) { x = x / 2; } console.timeEnd('Division (/ 2)'); } testDivision(100000000);
Bitwise Shift (>> 1)
function testBitwiseShift(iterations) { let x = 123456; console.time('Bitwise Shift (>> 1)'); for (let i = 0; i < iterations; i++) { x = x >> 1; } console.timeEnd('Bitwise Shift (>> 1)'); } testBitwiseShift(100000000);
Multiplication (* 0.5)
function testMultiplication(iterations) { let x = 123456; console.time('Multiplication (* 0.5)'); for (let i = 0; i < iterations; i++) { x = x * 0.5; } console.timeEnd('Multiplication (* 0.5)'); } testMultiplication(100000000);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Division (/ 2)
Bitwise Shift (>> 1)
Multiplication (* 0.5)
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Browser/OS:
Firefox 136 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Division (/ 2)
11.9 Ops/sec
Bitwise Shift (>> 1)
23.7 Ops/sec
Multiplication (* 0.5)
11.9 Ops/sec
Related benchmarks:
shift vs pop
shift vs pop with more cases
Number fixing
fast floor vs floor js
fast floor vs floor js vs unsafe floor
Deci binary partitioning
Compare Performance Code Complexity Without Original
Integer division test
div by 3 vs mul 0.333
Comments
Confirm delete:
Do you really want to delete benchmark?