Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
clamp vs bitClamp
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 16; Mobile; rv:152.0) Gecko/152.0 Firefox/152.0
Browser:
Firefox Mobile 152
Operating system:
Android
Device Platform:
Mobile
Date tested:
one month ago
bitClamp
1154.0M/s
clamp
272.5M/s
View exact numbers
Test name
Executions per second
✓
bitClamp
1,153,986,944 Ops/sec
clamp
272,452,064 Ops/sec
Script Preparation code:
window.clamp = (val, min, max) => val < min ? min : val > max ? max : val; window.bitClamp = (x, min, max) => { x = x - ((x - max) & ((max - x) >> 31)); return x - ((x - min) & ((x - min) >> 31)); }
Tests:
clamp
clamp(Math.random() * 100000000000000000, 52, 896987565547);
bitClamp
bitClamp(Math.random() * 100000000000000000, 52, 896987565547);