From b8f3889f57bb0652e221a6a9218eb6bec97a6a97 Mon Sep 17 00:00:00 2001 From: KATT Date: Fri, 20 Oct 2023 17:19:57 +0200 Subject: [PATCH 1/2] chore: add gzip --- benchmark/index.js | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/benchmark/index.js b/benchmark/index.js index 87f72ba1..af29f6e7 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -5,6 +5,7 @@ import { parse, stringify, uneval } from "devalue"; import c from "kleur"; import * as superjson from "superjson"; import { createTson, tsonDate, tsonRegExp, tsonSet } from "tupleson"; +import { gzipSync } from "zlib"; const obj = { array: [{ foo: 1 }, { bar: 2 }, { baz: 3 }], @@ -28,27 +29,19 @@ const devalue_stringified = stringify(obj); const arson_stringified = ARSON.stringify(obj); const tson_serialized = tson.stringify(obj); -console.log( - `superjson output: ${c.bold().cyan(superjson_serialized.length)} bytes`, -); - -console.log(`tson output: ${c.bold().cyan(tson_serialized.length)} bytes`); -// console.log(superjson_serialized); -console.log( - `devalue.uneval output: ${c.bold().cyan(devalue_unevaled.length)} bytes`, -); -// console.log(devalue_unevaled); -console.log( - `devalue.stringify output: ${c - .bold() - .cyan(devalue_stringified.length)} bytes`, -); -// console.log(devalue_stringified); -console.log(`arson output: ${c.bold().cyan(arson_stringified.length)} bytes`); -// console.log(arson_stringified); +const printSize = (label, str) => { + console.log( + `${label}: ${c.bold().cyan(str.length)} bytes / ${c + .bold() + .cyan(gzipSync(str).length)} bytes gzipped`, + ); +}; -// const superjson_deserialized = superjson.parse(superjson_serialized); -// const devalue_deserialized = eval(`(${devalue_unevaled})`); +printSize("superjson", superjson_serialized); +printSize("tson", tson_serialized); +printSize("devalue.uneval", devalue_unevaled); +printSize("devalue.stringify", devalue_stringified); +printSize("arson", arson_stringified); const iterations = 1e6; From 14b840791c9e8c6854e689376d5932680cbb5279 Mon Sep 17 00:00:00 2001 From: KATT Date: Fri, 20 Oct 2023 17:22:39 +0200 Subject: [PATCH 2/2] fix --- benchmark/index.js | 1 + cspell.json | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/benchmark/index.js b/benchmark/index.js index af29f6e7..48a16bed 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -20,6 +20,7 @@ const obj = { // obj.self = obj; const tson = createTson({ + nonce: () => "__", types: [tsonDate, tsonRegExp, tsonSet], }); diff --git a/cspell.json b/cspell.json index 88036209..021c63dd 100644 --- a/cspell.json +++ b/cspell.json @@ -9,12 +9,14 @@ "pnpm-lock.yaml" ], "words": [ + "clsx", "Codecov", "codespace", "commitlint", "contributorsrc", "conventionalcommits", "deferreds", + "gzipped", "Iterarable", "KATT", "kleur", @@ -32,7 +34,6 @@ "tsup", "tupleson", "unevaled", - "wontfix", - "clsx" + "wontfix" ] }