Benchmarks

September 19, 2019 ยท View on GitHub

  • CPU: i7 4790k @ 4.5GHz
  • RAM: 24GB CL9 1866MHz

Each benchmark is an average of 5 runs. Benchmark consists of compressing/decompressing a file in memory.

Decompression benchmarks are performed on files output by FraGag.Compression.Prs.

Contestants:

  • FraGag.Compression.Prs: Compiled under newest .NET Framework at the time of testing (4.7.2).
  • dlang-prs: Compiled under LDC2 (LDC 1.11.0-beta2).
  • prs-util (OnVar/Rust): Compiled with opt-level = 3 and `RUSTFLAGS="-C target-cpu=native" on the nightly toolchains.

Not benchmarking:

  • prsutil (Essen/Erlang): Not familliar with Erlang enough.
  • fuzziqer's utility: Failed to compile on Windows. Using Linux results would not be representative. Algorithmically identical to FraGag.Compression.Prs but in C++.

Extra Notes

FraGag.Compression.Prs: The highest performing overloads of the Compress/Decompress method have been used. To be precise, the overloads using MemoryStream under the hood (accepting byte arrays). The FileStream overloads are very slow.

dlang-prs is the only compressor which has an option of manually setting the sliding window size for compression, allowing for a speed-compression ratio adjustment.

C# implementations were measured using System.Diagnostics.Stopwatch. D implementations were measured using benchmark() Rust implementations were measured using https://github.com/ellisonch/rust-stopwatch


X64 Compression

Windows Executable, Mixed Compression

TSonic_win.exe: 5,132,288 bytes. (Sonic Heroes' executable)

CompressorNotesTime/msCompression Ratio/%Final Size/bytes
dlang-prs0x7FF Window299862.833,224,642
dlang-prs0x1FFF Window965257.112,931,333
Prs.NET0x1FF0 Window1448355.302,838,437
prs-util0x1FFF Window1653558.212,987,736

Medium Size, Highly Compressible

s01_P1.bin: 135,168 bytes Sonic Heroes object layout - huge lot of 0s.

CompressorNotesTime/msCompression Ratio/%Final Size/bytes
dlang-prs0x7FF Window2814.6119,748
dlang-prs0x1FFF Window8313.6818,497
Prs.NET0x1FF0 Window10913.5918,368
prs-util0x1FFF Window47213.9018,788

Medium Size, Realistic Use Case

VECTOR_LOCATOR.DFF: 169,637 bytes Medium, RenderWare Clump Model/Stream

CompressorNotesTime/msCompression Ratio/%Final Size/bytes
dlang-prs0x7FF Window8250.1585,079
dlang-prs0x1FFF Window25444.1574,890
Prs.NET0x1FF0 Window36743.5673,900
prs-util0x1FFF Window41945.5377,237

X86 Compression

Windows Executable, Mixed Compression

TSonic_win.exe: 5,132,288 bytes. (Sonic Heroes' executable)

CompressorNotesTime/msCompression Ratio/%Final Size/bytes
dlang-prs0x7FF Window409362.833,224,642
dlang-prs0x1FFF Window1333957.112,931,333
Prs.NET0x1FF0 Window2809155.302,838,437
prs-util0x1FFF Window2681558.212,987,736

Medium Size, Highly Compressible

s01_P1.bin: 135,168 bytes Sonic Heroes object layout - huge lot of 0s.

CompressorNotesTime/msCompression Ratio/%Final Size/bytes
dlang-prs0x7FF Window3914.6119,748
dlang-prs0x1FFF Window11013.6818,497
Prs.NET0x1FF0 Window17913.5918,368
prs-util0x1FFF Window53313.9018,788

Medium Size, Realistic Use Case

VECTOR_LOCATOR.DFF: 169,637 bytes Medium, RenderWare Clump Model/Stream

CompressorNotesTime/msCompression Ratio/%Final Size/bytes
dlang-prs0x7FF Window11650.1585,079
dlang-prs0x1FFF Window38644.1574,890
Prs.NET0x1FF0 Window71443.5673,900
prs-util0x1FFF Window66545.5377,237

X64 Decompression

Reminder: The PRS compressed files used for benchmarking decompression are the output of Prs.NET.

TSonic_win.exe

CompressorTime/ms
dlang-prs28.70
Prs.NET69.56
prs-util43.78

s01_P1.bin:

CompressorTime/ms
dlang-prs0.28
Prs.NET1.79
prs-util0.73

VECTOR_LOCATOR.DFF:

CompressorTime/ms
dlang-prs0.636
Prs.NET2.213
prs-util1.411

X86 Decompression

TSonic_win.exe:

CompressorTime/ms
dlang-prs31.97
Prs.NET101.79
prs-util55.63

s01_P1.bin:

CompressorTime/ms
dlang-prs0.29
Prs.NET2.44
prs-util0.86

VECTOR_LOCATOR.DFF:

CompressorTime/ms
dlang-prs0.654
Prs.NET3.014
prs-util1.626

Search Buffer Size Scaling (dlang-prs - X64)

A feature unique to dlang-prs is that it allows you to set the size of the search buffer used for compression; letting the user adjust between compression ratio and speed. Here is a data set of individual tests across each file; mapping the final file size and time taken together.

TSonic_win;

CompressorTime/msFile Size/bytes
0x1FFF96802,931,333
0x1C0085992,955,088
0x180075432,983,479
0x140064183,020,668
0x100052953,064,558
0xC0042123,128,102
0x80029733,223,750
0x40016763,386,723
0xFF5633,717,609
0x642954,048,881
0x101084,900,127
0x0A845,083,734
UncompressedN/A5,132,288
0x0405,773,827

A Windows executable is ideal for this kind of test as it contains all sorts of random data and the file contents are very mixed. The result set can be treated as a set of very realistic expectations.

s01_P1.bin (Medium Size, Highly Compressible):

CompressorTime/msFile Size/bytes
0x1FFF77.9618,497
0x1C0068.9918,612
0x180060.7718,783
0x140052.9818,936
0x100043.6719,151
0xC0035.5419,391
0x80027.4219,746
0x40016.8420,433
0xFF8.2021,980
0x645.9223,554
0x104.6437,768
0x0A4.5237,915
UncompressedN/A135,168
0x001.03152,067

VECTOR_LOCATOR.DFF (Medium Size, RW Clump/3D Model):

CompressorTime/msFile Size/bytes
0x1FFF242.3474,890
0x1C00219.1775,346
0x1800190.1676,165
0x1400171.2877,068
0x1000142.8181,219
0xC00111.2682,975
0x80079.5385,066
0x40044.0388,529
0xFF14.8594,096
0x647.14102,682
0x103.99123,146
0x0A2.37144,389
UncompressedN/A169,637
0x001.24190,844

Graph A Graph B Graph C