Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Replace decimal separator in number string
(version: 0)
Test NumberFormat.formatToParts().map().join() vs toString().replace()
Comparing performance of:
IntlFormat.formatToParts().map().join() vs number.toString().replace('.', ',');
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
window.format = new Intl.NumberFormat('en', { style: 'decimal', notation: 'standard', signDisplay: 'auto' });
Tests:
IntlFormat.formatToParts().map().join()
const number = 1234.56; window.format.formatToParts(number).map((val) => (val.type === 'decimal' ? ',' : val.value)).join('');
number.toString().replace('.', ',');
const number = 1234.56; number.toString().replace('.', ',');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
IntlFormat.formatToParts().map().join()
number.toString().replace('.', ',');
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?