MCPcopy Create free account
hub / github.com/arfct/itty-bitty / testCompression

Function testCompression

docs/bitty.js:197–217  ·  view source on GitHub ↗
(rawData)

Source from the content-addressed store, hash-verified

195}
196
197async function testCompression(rawData) {
198 console.group("Testing compression")
199 let t1 = performance.now()
200 let gz = await compressData(rawData, GZIP_MARKER);
201 let t2 = performance.now()
202 console.log("gz", dataToBase64(gz).length, Math.round(t2 - t1));
203 let xz = await compressData(rawData, LZMA_MARKER);
204 let t3 = performance.now()
205 console.log("xz", dataToBase64(xz).length, Math.round(t3 - t2));
206
207 console.groupEnd();
208
209 // let ungz = await decompressData(gz, GZIP_MARKER);
210 // let unxz = await decompressData(xz, LZMA_MARKER);
211
212 // console.log("unzip", ungz == rawData, unxz==rawData,{ungz, unxz,rawData,
213 // raw: byteArrayToString(rawData).substring(684),
214 // ungzs: byteArrayToString(ungz).substring(684),
215 // unxzs: byteArrayToString(unxz).substring(684)
216 // }, (byteArrayToString(ungz)) == byteArrayToString(unxz))
217}
218
219async function compressData(data, encoding = GZIP_MARKER, callback) {
220 console.debug("Compressing with", encoding)

Callers

nothing calls this directly

Calls 2

compressDataFunction · 0.85
dataToBase64Function · 0.85

Tested by

no test coverage detected