Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Coordinate test 3
(version: 0)
Comparing performance of:
Conditional comparison vs Bitwise comparison vs Other test
Created:
6 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var width = 480; var halfWidth = width >> 1;
Tests:
Conditional comparison
var xPos = Math.random() * width; var xQuadLeft = xPos < halfWidth ? 0 : 1;
Bitwise comparison
var xPos = Math.random() * width; var diff = xPos ^ halfWidth; diff |= diff >> 1; diff |= diff >> 2; diff |= diff >> 4; diff |= diff >> 8; diff |= diff >> 16; diff &= ~(diff >> 1) | 0x80000000; diff &= (xPos ^ 0x80000000) & (halfWidth ^ 0x7fffffff); var xQuad = !!diff;
Other test
var xPos = Math.random() * width; var xQuad = xPos ^ halfWidth && ( !(halfWidth ^ 0) || ( (xPos / halfWidth) | 0 ) );
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Conditional comparison
Bitwise comparison
Other test
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Coordinate test
Coordinate test 4
Coordinate test 5
Coordinate test 6
Coordinate test 7
Comments
Confirm delete:
Do you really want to delete benchmark?