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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15
Browser:
Safari 17
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Ternary with cache
3.4M/s
Math.max
2.4M/s
Ternary and operate again
2.3M/s
View exact numbers
Test name
Executions per second
✓
Ternary with cache
3,394,396 Ops/sec
Math.max
2,380,877 Ops/sec
Ternary and operate again
2,303,230 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;