Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
branchless min vs Math.min vs cached min vs ternary vs if (2 values)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
Browser:
Chrome 140
Operating system:
Windows
Device Platform:
Desktop
Date tested:
9 months ago
Benchmark engine:
Benchmark.js
Min w/ Ternary
29.1M/s
Math.min (uncached)
27.7M/s
branchless
26.3M/s
Math.min (cached)
26.0M/s
Min w/ If
25.9M/s
View exact numbers
Test name
Executions per second
✓
Min w/ Ternary
29,062,792 Ops/sec
Math.min (uncached)
27,714,982 Ops/sec
branchless
26,277,204 Ops/sec
Math.min (cached)
26,020,846 Ops/sec
Min w/ If
25,945,506 Ops/sec
Script Preparation code:
var rnd = Math.random; var branchlessMin = (a, b) => (a > b) * b + (a <= b) * a; var mathMin = Math.min; var minTernary = (a, b) => a > b ? b : a; var minIf = (a, b) => { if (a > b) { return b; } else { return a; }; };
Tests:
branchless
return branchlessMin(rnd(), rnd());
Math.min (cached)
return mathMin(rnd(), rnd());
Math.min (uncached)
return Math.min(rnd(), rnd());
Min w/ Ternary
return minTernary(rnd(), rnd())
Min w/ If
return minIf(rnd(), rnd())