Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Math max or ternary operator
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/122.0.0.0 Safari/537.36
Browser:
Chrome 122
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Ternary with cache
3.7M/s
Math.max
2.6M/s
Ternary and operate again
2.5M/s
View exact numbers
Test name
Executions per second
✓
Ternary with cache
3,675,976 Ops/sec
Math.max
2,618,732 Ops/sec
Ternary and operate again
2,486,848 Ops/sec
Script Preparation code:
var a = 3452; var b = 5672;
Tests:
Math.max
var c = Math.max(a + b, a * b);
Ternary and operate again
var d = a + b > a * b ? a + b : a * b;
Ternary with cache
var e = a + b; var f = a * b; var h = e > f ? e : f;