Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
test ABS 4
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Math.abs
71.1 Ops/sec
abs
83.6 Ops/sec
Custom1
55.8 Ops/sec
Custom2
83.2 Ops/sec
Compare
67.1 Ops/sec
Bitshift
83.6 Ops/sec
Script Preparation code:
var abs = Math.abs var x = -0.00034254146579137945; var cycle_counter = 10000000;
Tests:
Math.abs
for(i=0; i<cycle_counter; i++){ var result = Math.abs(x); }
abs
for(i=0; i<cycle_counter; i++){ var result = abs(x); }
Custom1
for(i=0; i<cycle_counter; i++){ var negative = x < 0.0 ? 1 : 0; var result = x - x * 2.0 * negative; }
Custom2
for(i=0; i<cycle_counter; i++){ var result = x & -1; }
Compare
for(i=0; i<cycle_counter; i++){ var result = x < 0 ? -x : x }
Bitshift
for(i=0; i<cycle_counter; i++){ var result = (x ^ (x >> 31)) - (x >> 31) }