Created
March 10, 2025 03:26
-
-
Save manzt/2337d6e131a78c20ffb4c8196de0b419 to your computer and use it in GitHub Desktop.
This file contains 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
import * as assert from "jsr:@std/[email protected]"; | |
import * as fflate from "npm:[email protected]"; | |
import * as pako from "npm:[email protected]"; | |
const base = new URL( | |
"https://raw.githubusercontent.com/zarr-developers/zarr_implementations/5dc998ac72/examples/zarr.zr/gzip/.zarray", | |
); | |
const BYTES = await fetch(new URL("0.0.0", base)) | |
.then((r) => r.arrayBuffer()) | |
.then((b) => new Uint8Array(b)); | |
const REFERENCE = fflate.gunzipSync(BYTES); | |
Deno.bench("DecompressionStream", { baseline: true }, async () => { | |
const compressedResponse = new Response(BYTES); | |
const decompressedResponse = new Response( | |
compressedResponse.body!.pipeThrough( | |
new DecompressionStream("gzip"), | |
), | |
); | |
const buffer = await decompressedResponse.arrayBuffer(); | |
assert.assert(new Uint8Array(buffer).length === REFERENCE.length); | |
}); | |
Deno.bench("fflate.gunzip", () => { | |
const result = fflate.gunzipSync(BYTES); | |
assert.assert(result.length === REFERENCE.length); | |
}); | |
Deno.bench("pako.inflate", () => { | |
const result = pako.inflate(BYTES); | |
assert.assert(result.length === REFERENCE.length); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment