<script src="https://cdn.jsdelivr.net/npm/zlibjs@0.3.1/bin/rawdeflate.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/zlibjs@0.3.1/bin/rawinflate.min.js"></script>
var enc = new TextEncoder();
var a = new Uint8Array([100 * 1024]);
for (var i; i < 100 * 1024; i++)
a[i] = Math.floor(Math.random() * 256)
var deflate = new Zlib.RawDeflate(a);
var ca = deflate.compress();
var inflate = new Zlib.RawInflate(ca);
var plain = inflate.decompress();
var inflate = new Zlib.RawInflate(ca,{
bufferType : Zlib.RawInflate.BufferType.BLOCK,
bufferSize : 32
});
var plain = inflate.decompress();
var inflate = new Zlib.RawInflate(ca,{
bufferType : Zlib.RawInflate.BufferType.BLOCK,
bufferSize : 64
});
var plain = inflate.decompress();
var inflate = new Zlib.RawInflate(ca,{
bufferType : Zlib.RawInflate.BufferType.BLOCK,
bufferSize : 128
});
var plain = inflate.decompress();
var inflate = new Zlib.RawInflate(ca,{
bufferType : Zlib.RawInflate.BufferType.BLOCK,
bufferSize : 256
});
var plain = inflate.decompress();
var inflate = new Zlib.RawInflate(ca,{
bufferType : Zlib.RawInflate.BufferType.BLOCK,
bufferSize : 512
});
var plain = inflate.decompress();
var inflate = new Zlib.RawInflate(ca,{
bufferType : Zlib.RawInflate.BufferType.BLOCK,
bufferSize : 1024
});
var plain = inflate.decompress();
var inflate = new Zlib.RawInflate(ca,{
bufferType : Zlib.RawInflate.BufferType.BLOCK,
bufferSize : 2048
});
var plain = inflate.decompress();
var inflate = new Zlib.RawInflate(ca,{
bufferType : Zlib.RawInflate.BufferType.BLOCK,
bufferSize : 4096
});
var plain = inflate.decompress();
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
Default | |
Block Size 32 | |
Block Size 64 | |
Block Size 128 | |
Block Size 256 | |
Block Size 512 | |
Block Size 1024 | |
Block Size 2048 | |
Block Size 4096 |
Test name | Executions per second |
---|---|
Default | 14971.2 Ops/sec |
Block Size 32 | 71714.7 Ops/sec |
Block Size 64 | 72885.3 Ops/sec |
Block Size 128 | 71152.6 Ops/sec |
Block Size 256 | 70534.2 Ops/sec |
Block Size 512 | 67839.0 Ops/sec |
Block Size 1024 | 56247.5 Ops/sec |
Block Size 2048 | 54034.4 Ops/sec |
Block Size 4096 | 43645.1 Ops/sec |
Let's break down the test cases and options being compared.
What is being tested?
The test case measures the performance of different block sizes in decompressing a ZIP file using the Zlib.RawInflate
library. The test creates a compressed ZIP file (ca
) by compressing an array of random data with Zlib.RawDeflate
. Then, it tests decompression at various block sizes (32, 64, 128, 256, 512, 1024, 2048, and 4096) using the Zlib RAW
protocol.
Options being compared
The test compares the performance of each block size in decompressing the ZIP file. The options are:
Browser performance
The test measures the performance of each block size in different browsers on Android devices:
What does it mean?
The results indicate that smaller block sizes (32, 64, and 128) are faster than larger block sizes (256, 512, 1024, and 2048). The default block size is the slowest. The performance difference between different block sizes suggests that Zlib RAW
optimization for varying block sizes can have a significant impact on decompression speed.
Keep in mind that this test is just one aspect of measuring Zlib
performance, and there may be other factors affecting overall compression/decompression efficiency.