JSON.stringinfy vs String

Benchmark created on


Setup

const data = [];

for(let i = 1; i <= 100; i ++) {
	data.push('Hello World');
	data.push(i);
	data.push(['foo', 'bar']);
	data.push(null);
}

Test runner

Ready to run.

Testing in
TestOps/sec
JSON.stringify
data.forEach((value) => JSON.stringify(value));
ready
String
data.forEach((value) => String(value));
ready

Revisions

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