Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
World's Fasted Min Max
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser:
Chrome 133
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
ternary
87.1M/s
if else
83.8M/s
math min/max
81.8M/s
View exact numbers
Test name
Executions per second
✓
ternary
87,118,184 Ops/sec
if else
83,797,960 Ops/sec
math min/max
81,794,632 Ops/sec
Script Preparation code:
function minmax1 (value) { return value < 0 ? 0 : value > 255 ? 255 : value } function minmax2 (value) { if (value < 0) { return 0 } else if (value > 255) { return 255 } return value } function minmax3 (value) { return Math.min(Math.max(value, 0), 255) }
Tests:
ternary
minmax1(-123);minmax1(123);minmax1(123123);
if else
minmax2(-123);minmax2(123);minmax2(123123);
math min/max
minmax3(-123);minmax3(123);minmax3(123123);