From: Jérôme Benoit Date: Sat, 30 Mar 2024 20:51:29 +0000 (+0100) Subject: feat: add JSON.stringify benchmark X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=26792d4d3d5f5666dd72e7778e3baa8d370d9b03;p=benchmarks-js.git feat: add JSON.stringify benchmark Signed-off-by: Jérôme Benoit --- diff --git a/json-stringify.mjs b/json-stringify.mjs new file mode 100644 index 0000000..de8b81a --- /dev/null +++ b/json-stringify.mjs @@ -0,0 +1,22 @@ +import { bench, group, run } from 'mitata' + +const sampleObj = { + name: 'Sid', + age: 29, + engineer: true, + expertise: ['html', 'css', 'react'], + address: { + city: 'New york', + state: 'NY' + } +} + +group('JSON stringify', () => { + bench('JSON.stringify', () => { + JSON.stringify(sampleObj) + }) +}) + +await run({ + units: true +}) diff --git a/package.json b/package.json index a4ad1bc..d8b4aad 100644 --- a/package.json +++ b/package.json @@ -35,9 +35,10 @@ "preinstall": "npx --yes only-allow pnpm", "prepare": "node prepare.mjs", "benchmark:busy-wait": "node busy-wait.mjs", - "benchmark:empty-array": "node empty-array.mjs", "benchmark:deep-clone-object": "node deep-clone-object.mjs", "benchmark:deep-merge-object": "node deep-merge-object.mjs", + "benchmark:json-stringify": "node json-stringify.mjs", + "benchmark:empty-array": "node empty-array.mjs", "benchmark:shallow-clone-object": "node shallow-clone-object.mjs", "benchmark:is-empty-object": "node is-empty-object.mjs", "benchmark:is-undefined": "node is-undefined.mjs",