diff options
author | 2023-05-17 12:12:42 -0700 | |
---|---|---|
committer | 2023-05-17 12:12:42 -0700 | |
commit | 6c847f638f2cfaf3d1b81df248a95301d0bfdded (patch) | |
tree | 9d5a35e77b66885efaaa165147d440d0e137f81f /bench/snippets | |
parent | 8d90d79587f710de28cdc1c9b212ee18e3fb1bfa (diff) | |
download | bun-6c847f638f2cfaf3d1b81df248a95301d0bfdded.tar.gz bun-6c847f638f2cfaf3d1b81df248a95301d0bfdded.tar.zst bun-6c847f638f2cfaf3d1b81df248a95301d0bfdded.zip |
microbenchmark for json.parse / stringify
Diffstat (limited to 'bench/snippets')
-rw-r--r-- | bench/snippets/json-parse-stringify.mjs | 57 |
1 files changed, 57 insertions, 0 deletions
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(); |