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
Go 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
abs
509/s
pow
507/s
** 2
502/s
View exact numbers
Test name
Executions per second
✓
abs
509 Ops/sec
pow
507 Ops/sec
** 2
502 Ops/sec
Related benchmarks
Math.pow(x, 2) vs. x * x
Get max from an array of numbers (Math.max vs. iteration) V3
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?