From 6c847f638f2cfaf3d1b81df248a95301d0bfdded Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 17 May 2023 12:12:42 -0700 Subject: microbenchmark for json.parse / stringify --- bench/snippets/json-parse-stringify.mjs | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 bench/snippets/json-parse-stringify.mjs (limited to 'bench/snippets') diff --git a/bench/snippets/json-parse-stringify.mjs b/bench/snippets/json-parse-stringify.mjs new file mode 100644 index 000000000..752c59a75 --- /dev/null +++ b/bench/snippets/json-parse-stringify.mjs @@ -0,0 +1,57 @@ +import { bench, run } from "./runner.mjs"; + +var obj = { + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": false, + "rest": { + "handleErrors": false, + "normalizeHttpPath": false, + "xml": false, + }, + "json": { + "strict": false, + "limit": "100kb", + }, + "urlencoded": { + "extended": true, + "limit": "100kb", + boop: { + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": false, + "rest": { + "handleErrors": false, + "normalizeHttpPath": false, + "xml": false, + }, + "json": { + "strict": false, + "limit": "100kb", + }, + "urlencoded": { + "extended": true, + "limit": "100kb", + }, + "cors": false, + }, + }, + }, + "cors": false, + }, +}; +var big = JSON.stringify(obj); + +bench("JSON.parse(big)", () => { + globalThis.foo = JSON.parse(big); +}); + +bench("JSON.stringify(big)", () => { + globalThis.bar = JSON.stringify(obj); +}); + +await run(); -- cgit v1.2.3