Created
April 25, 2025 14:12
-
-
Save kibibites/ee0f6ea3f1f6595a305736db4cec8eed to your computer and use it in GitHub Desktop.
benchmarking different encoders/decoders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// curl https://microsoftedge.github.io/Demos/json-dummy-data/1MB-min.json > test.json | |
import { decode as decodeMsgpack, encode as encodeMsgpack } from "npm:@msgpack/msgpack"; | |
import { decode as decodeCbor, encode as encodeCbor } from "npm:cbor-x"; | |
const encoder = new TextEncoder(), | |
decoder = new TextDecoder(), | |
data = JSON.parse(Deno.readTextFileSync("test.json")); | |
Deno.bench("@msgpack/msgpack", () => { | |
const encoded = encodeMsgpack(data); | |
const decoded = decodeMsgpack(encoded); | |
}) | |
Deno.bench("cbor-x", { baseline: true }, () => { | |
const encoded = encodeCbor(data); | |
const decoded = decodeCbor(encoded); | |
}) | |
Deno.bench("json+textencoder", (b) => { | |
const encoded = encoder.encode(JSON.stringify(data)); | |
const decoded = JSON.parse(decoder.decode(encoded)); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment