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
Test name
Executions per second
abs
738641472.0 Ops/sec
ternary
744681152.0 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