-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
import { compress, uncompress } from 'snappyjs' | ||
import { snappyUncompress as uncompressWasm } from '../hysnappy.js' | ||
|
||
const fileSize = 200_000_000 | ||
|
||
const compressed = await time(`generate and compress ${fileSize.toLocaleString()}`, () => { | ||
// Generate input array with random data | ||
const input = new Uint8Array(fileSize) | ||
for (let i = 0; i < fileSize; i++) { | ||
input[i] = Math.floor(Math.random() * 128) | ||
} | ||
return compress(input) | ||
}) | ||
|
||
const output = new Uint8Array(fileSize) | ||
|
||
await time('uncompress wasm', () => uncompressWasm(compressed, output)) | ||
|
||
// await time('uncompress snappyjs', () => uncompress(compressed, output)) | ||
|
||
async function time(name, fn) { | ||
const start = performance.now() | ||
const output = await fn() | ||
const ms = performance.now() - start | ||
console.log(`${name} took ${ms} ms`) | ||
return output | ||
} |
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
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