zztaeha

A compression benchmark, right in your browser.

kokyu is deflate, zlib, gzip and zip for every JavaScript runtime, in TypeScript with no dependencies. Pick a sample, or a file or folder of your own, and kokyu compresses it, decompresses it again and times both. fflate, one of the most downloaded compression libraries on npm, runs the same job beside it, so the numbers have something to stand against. Nothing you pick leaves your browser.

Input
Or your own
Format
API

Pick an input and press Run. Nothing leaves your browser.

The calls behind it

What each run calls, for the format you pick. Both libraries are called the way their own docs show, at the level you choose.

kokyu

import { gzip, gunzip, gzipAsync, gunzipAsync } from 'kokyu'

const packed = gzip(data, { level: 6 })
const back = gunzip(packed)

// Off the main thread, in kokyu's pool of workers
const packedAsync = await gzipAsync(data, { level: 6 })
const backAsync = await gunzipAsync(packedAsync)

fflate

import { gzipSync, gunzipSync, gzip, gunzip } from 'fflate'

const packed = gzipSync(data, { level: 6 })
const back = gunzipSync(packed)

// Off the main thread, in a worker started for the call
gzip(data, { level: 6 }, (err, packedAsync) => {
  gunzip(packedAsync, (err, backAsync) => {})
})

How it's measured

  • Both libraries get the same bytes, format and level. The samples come from one seed, so every visit gets the same ones.
  • A folder goes into zip as it is, one entry per file at its path in the folder. gzip, zlib and raw deflate take a single stream, so for them its files are joined end to end.
  • There's no size limit but your device's memory. A run holds the input, every output and what they decode to, so it needs a few times the input's size, and since each call runs at least four times, big inputs take a while.
  • Each time is the median of 3 to 15 rounds. In a round each library runs for at least 25 ms, so even a coarse browser timer reads it closely, and the one that goes first swaps every round.
  • For decompression, each library decodes every output, kokyu's and fflate's, so both decode the same bytes.
  • Every output is decoded by both libraries and compared with the input byte for byte. If one doesn't match, the check row says so.
  • Sync runs both libraries' one-shot calls in a worker, so the page stays responsive while they work.
  • Async calls each library's own async API from this page. kokyu runs inputs under 16 KB right away and keeps a pool of workers, while fflate starts a worker for every call, which is most of the difference on small inputs.
  • The numbers are your device's own, and other busy tabs make them noisier. A KB here is 1,024 bytes, and an MB 1,024 KB.

About fflate

fflate 0.8.3 is by 101arrowz, under the MIT license. Its source is at github.com/101arrowz/fflate.

Type to search.