Created
March 10, 2025 03:26
-
-
Save manzt/2337d6e131a78c20ffb4c8196de0b419 to your computer and use it in GitHub Desktop.
Revisions
-
manzt created this gist
Mar 10, 2025 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ 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); });