Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Compare the ways to convert String to Number in JS
Compare the most popular ways to convert string to number
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Android
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
*1
64/s
>>0
64/s
parseInt
63/s
~~
62/s
+
60/s
Number
51/s
View exact numbers
Test name
Executions per second
✓
*1
64 Ops/sec
>>0
64 Ops/sec
parseInt
63 Ops/sec
~~
62 Ops/sec
+
60 Ops/sec
Number
51 Ops/sec
Script Preparation code:
const minimum = 1 const maximum = 1000 var arr = Array.from({ length: 1000000 }, () => Math.floor(Math.random() * (maximum - minimum + 1)) + minimum)
Tests:
Number
return arr.map((el) => Number(el))
parseInt
return arr.map((el) => parseInt(el))
>>0
return arr.map((el) => el >> 0)
*1
return arr.map((el) => el * 1)
~~
return arr.map((el) => ~~el)
+
return arr.map((el) => +el)