Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
abs vs ** 2 vs math.pow
(version: 1)
Comparing performance of:
abs vs pow vs ** 2
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const arr = Array.from({ length: 100_000 }, () => (Math.random()));
Tests:
abs
var b = arr.map((num) => Math.abs(num));
pow
var b = arr.map((num) => Math.pow(num, 2));
** 2
var b = arr.map((num) => num ** 2);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
abs
pow
** 2
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
abs
509.0 Ops/sec
pow
506.7 Ops/sec
** 2
502.4 Ops/sec
Related benchmarks:
maxddddd2
Math.pow(x, 2) vs. x * x
Get max from an array of numbers (Math.max vs. iteration)
Get max from an array of numbers (Math.max vs. iteration) V3
Fill an MxN 2D nested array with random numbers
int to string convertation
Exponentiation Test
Exponentiation Test Quart
Compare the ways to convert String to Number in JS +
Comments
Confirm delete:
Do you really want to delete benchmark?