diff options
author | Florian Dold <florian@dold.me> | 2021-08-20 13:31:03 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-08-20 13:31:03 +0200 |
commit | 859a8734c87d5e5081d7b0aa02cb538a7c801eac (patch) | |
tree | d2e9163479eb56ec382c842d62ce39fe30d450a4 /test/1-size.ts | |
download | node-vendor-859a8734c87d5e5081d7b0aa02cb538a7c801eac.tar.gz node-vendor-859a8734c87d5e5081d7b0aa02cb538a7c801eac.tar.bz2 node-vendor-859a8734c87d5e5081d7b0aa02cb538a7c801eac.zip |
Squashed 'fflate/' content from commit b786929
git-subtree-dir: fflate
git-subtree-split: b786929a368521e9cfcdcf7490a8e77485d5a253
Diffstat (limited to 'test/1-size.ts')
-rw-r--r-- | test/1-size.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/1-size.ts b/test/1-size.ts new file mode 100644 index 0000000..c2cc247 --- /dev/null +++ b/test/1-size.ts @@ -0,0 +1,24 @@ +import { testSuites, workers, bClone } from './util'; +import { writeFileSync } from 'fs'; +import { join } from 'path'; +import { performance } from 'perf_hooks'; +import * as assert from 'uvu/assert'; + +const sizePerf: Record<string, Record<string, [number, number]>> = {}; + +testSuites({ + async main(file, name) { + sizePerf[name] = {}; + for (const lib of (['fflate', 'pako', 'uzip', 'zlib'] as const)) { + const clone = bClone(file); + const ts = performance.now(); + sizePerf[name][lib] = [(await workers[lib].deflate([clone, { level: 9 }], [clone.buffer])).length, performance.now() - ts]; + } + for (const lib of ['pako', 'uzip', 'zlib']) { + // Less than 5% larger + assert.ok(((sizePerf[name].fflate[0] - sizePerf[name][lib][0]) / sizePerf[name][lib][0]) < 0.05); + } + } +}).then(() => { + writeFileSync(join(__dirname, 'results', 'longTimings.json'), JSON.stringify(sizePerf, null, 2)); +})
\ No newline at end of file |