Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
String to number conversion in Vanilla JS + number to string
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
nothing
17.5M/s
`${}`
15.7M/s
+
7.6M/s
String()
6.6M/s
Number
4.9M/s
parseFloat
4.5M/s
parseInt
4.1M/s
View exact numbers
Test name
Executions per second
✓
nothing
17,533,264 Ops/sec
`${}`
15,653,598 Ops/sec
+
7,556,912 Ops/sec
String()
6,624,634 Ops/sec
Number
4,914,663 Ops/sec
parseFloat
4,494,251 Ops/sec
parseInt
4,113,091 Ops/sec
Script Preparation code:
var toTest = [undefined, null, '-1','-1.1', '1', '100000', 'aaaa']; var toTestString = ['uuid', 1, 100000, 'abcdefghij', 23456, 345, '1234']
Tests:
+
toTest.map((item) => (+item));
Number
toTest.map(Number);
parseInt
toTest.map(parseInt);
parseFloat
toTest.map(parseFloat);
String()
toTestString.map(String)
`${}`
toTestString.map(k => `${k}`)
nothing
toTestString.map(k => k)