Intl.NumberFormat vs toLocalString notation compact

Benchmark created on


Setup

var a;

const formatter = new Intl.NumberFormat("en-US", { notation: 'compact' })

Test runner

Ready to run.

Testing in
TestOps/sec
Intl.NumberFormat
a = new Intl.NumberFormat("en-US", { notation: 'compact' }).format(1000000);
ready
Intl.NumberFormat with pre init
a = formatter.format(1000000);
ready
toLocaleString
a = (1000000).toLocaleString("en-US", {
    notation: 'compact'
});
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.