Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Abs vs ternary to find difference between two number
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/115.0
Browser:
Firefox 115
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
2 years ago
ternary
744.7M/s
abs
738.6M/s
View exact numbers
Test name
Executions per second
✓
ternary
744,681,152 Ops/sec
abs
738,641,472 Ops/sec
Script Preparation code:
var one = 5 var two = 2
Tests:
abs
var a = Math.abs(two - one)
ternary
var a = two > one ? two - one : one - two