Convert Figma logo to code with AI

inikep logolzbench

lzbench is an in-memory benchmark of open-source compressors

1,040
203
1,040
10

Top Related Projects

26,020

Zstandard - Fast real-time compression algorithm

11,571

Extremely Fast Compression algorithm

6,472

A fast compressor/decompressor

10,740

Extremely fast non-cryptographic hash algorithm

Quick Overview

lzbench is an in-memory benchmarking tool for lossless compression algorithms. It provides a comprehensive comparison of various compression libraries and algorithms, measuring their speed and compression ratios. This project is particularly useful for developers and researchers working on data compression or seeking the most efficient compression method for their specific use case.

Pros

  • Supports a wide range of compression algorithms and libraries
  • Provides detailed performance metrics, including compression and decompression speeds
  • Easy to use and extend with new algorithms
  • Cross-platform compatibility (Windows, Linux, macOS)

Cons

  • Requires manual compilation of some compression libraries
  • May not reflect real-world performance for all use cases
  • Limited documentation for advanced usage and customization
  • Some older or less common algorithms may not be included

Getting Started

To get started with lzbench, follow these steps:

  1. Clone the repository:

    git clone https://github.com/inikep/lzbench.git
    
  2. Navigate to the lzbench directory:

    cd lzbench
    
  3. Compile the project:

    make
    
  4. Run lzbench with a sample file:

    ./lzbench -t1,1 -eall file_to_compress
    

This will run a benchmark using all available compression algorithms on the specified file, with one iteration and one thread. Adjust the parameters as needed for your specific use case.

Competitor Comparisons

26,020

Zstandard - Fast real-time compression algorithm

Pros of zstd

  • Highly optimized compression algorithm with excellent speed/compression ratio
  • Extensive documentation and active development by Facebook
  • Supports dictionary compression for improved efficiency on small files

Cons of zstd

  • Focused solely on zstd compression, not a benchmarking tool
  • Less flexibility in comparing multiple compression algorithms
  • Steeper learning curve for users unfamiliar with zstd specifics

Code comparison

zstd:

size_t ZSTD_compress(void* dst, size_t dstCapacity,
                     const void* src, size_t srcSize,
                     int compressionLevel);

lzbench:

int64_t lzbench_compress(char *inbuf, size_t insize,
                         char *outbuf, size_t outsize,
                         size_t level, const char *params,
                         char *workmem);

Key differences

  • lzbench is a benchmarking tool for multiple compression algorithms, including zstd
  • zstd focuses on providing a high-performance compression algorithm
  • lzbench offers a unified interface for various compression methods, while zstd has a specialized API
  • zstd provides more advanced features like dictionary compression and streaming API
  • lzbench is better suited for comparing different algorithms, while zstd excels in production use cases
11,571

Extremely Fast Compression algorithm

Pros of lz4

  • Focused on a single, highly optimized compression algorithm (LZ4)
  • Extensive documentation and API references
  • Widely adopted and integrated into many popular projects

Cons of lz4

  • Limited to LZ4 compression only
  • Less flexibility for comparing different compression algorithms

Code comparison

lz4:

#define LZ4_COMPRESSBOUND(isize)   ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)

lzbench:

#define LZBENCH_COMPRESSOR(NAME, LEVEL) \
    {NAME, LEVEL, lzbench_ ## NAME ## _init, lzbench_ ## NAME ## _compress, lzbench_ ## NAME ## _decompress, lzbench_ ## NAME ## _deinit}

Key differences

lzbench is a benchmarking tool that supports multiple compression algorithms, including LZ4. It allows users to compare the performance of various compression methods. On the other hand, lz4 is dedicated to the LZ4 compression algorithm, providing a highly optimized implementation and extensive documentation for this specific method.

lzbench offers more flexibility for testing and comparing different compression algorithms, while lz4 focuses on providing the best possible implementation and support for the LZ4 algorithm. The choice between the two depends on whether you need to benchmark multiple algorithms or specifically work with LZ4 compression.

6,472

A fast compressor/decompressor

Pros of Snappy

  • Highly optimized for speed, focusing on fast compression and decompression
  • Developed and maintained by Google, ensuring reliability and ongoing support
  • Widely adopted and integrated into many popular projects and databases

Cons of Snappy

  • Limited compression ratio compared to other algorithms
  • Primarily designed for specific use cases, may not be suitable for all scenarios
  • Less flexibility in terms of compression levels and customization options

Code Comparison

Snappy

char* output = new char[snappy::MaxCompressedLength(input_length)];
size_t output_length;
snappy::RawCompress(input_data, input_length, output, &output_length);

LZBench

lzbench_compress_t compress = compressor_db[compressor_id].compress;
size_t compressed_size = compress(input_data, input_length, compressed_buf, compressed_buf_size);

Key Differences

  • LZBench is a benchmarking tool for various compression algorithms, while Snappy is a specific compression algorithm
  • LZBench allows for comparison of multiple algorithms, whereas Snappy focuses on its own implementation
  • Snappy prioritizes speed over compression ratio, while LZBench enables testing of algorithms with different priorities

Use Cases

  • Snappy: Ideal for scenarios requiring fast compression/decompression with moderate size reduction
  • LZBench: Useful for developers and researchers comparing different compression algorithms' performance
10,740

Extremely fast non-cryptographic hash algorithm

Pros of xxHash

  • Focused on fast non-cryptographic hash functions
  • Provides multiple hash algorithms (XXH32, XXH64, XXH3)
  • Extensive language support through official and community bindings

Cons of xxHash

  • Limited to hash functions, not a comprehensive benchmarking tool
  • Doesn't provide comparisons with other compression algorithms
  • Less versatile for general-purpose compression testing

Code Comparison

xxHash (XXH64 function):

XXH_FORCE_INLINE XXH64_hash_t XXH64_round(XXH64_hash_t acc, XXH64_hash_t input)
{
    acc += input * PRIME64_2;
    acc  = XXH_rotl64(acc, 31);
    acc *= PRIME64_1;
    return acc;
}

lzbench (benchmarking function):

int64_t lzbench_compress(char *inbuf, size_t insize, char *outbuf, size_t outsize, size_t level, char* temp)
{
    return compressor(inbuf, insize, outbuf, outsize, level);
}

Summary

xxHash is a specialized library for fast non-cryptographic hash functions, while lzbench is a comprehensive benchmarking tool for various compression algorithms. xxHash offers high-performance hash functions with broad language support, but lacks the versatility and comparison capabilities of lzbench for general compression testing. The code examples highlight their different focuses: xxHash on efficient hashing and lzbench on benchmarking multiple compressors.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Introduction

lzbench is an in-memory benchmarking tool for open-source compressors. It integrates all compressors into a single executable. Initially, an input file is loaded into memory, after which each compressor is used to compress and decompress the file, ensuring the decompressed output matches the original. This method provides the advantage of compiling all compressors with the same compiler and optimizations. However, it requires access to the source code of each compressor, meaning e.g. Slug and lzturbo are not included.

Status
Build Status

The list of changes in lzbench is available in the CHANGELOG.

Contributor information can be found in CONTRIBUTING.md.

Usage

usage: lzbench [options] input [input2] [input3]

For example:
  lzbench -ezstd filename = selects all levels of zstd
  lzbench -ebrotli,2,5/zstd filename = selects levels 2 & 5 of brotli and zstd
  lzbench -t3,5 fname = 3 sec compression and 5 sec decompression loops
  lzbench -t0,0 -i3,5 fname = 3 compression and 5 decompression iterations
  lzbench -o1c4 fname = output markdown format and sort by 4th column
  lzbench -ezlib -j -r dirname/ = test zlib on all files in directory, recursively

For complete list of options refer to manual in doc directory which contains more detailed documentation.

Building

To compile, you need a C and C++ compiler that is GNUC-compatible, such as GCC, LLVM/Clang, or ICC. It is recommended to use GCC 7.1+ or Clang 6.0+.

For Linux/MacOS/MinGW (Windows):

make -j$(nproc)

The default linking for Linux is dynamic and static for Windows. This can be changed with make BUILD_STATIC=0/1.

For complete building instruction, with troubleshooting refer to BUILD.md.

Supported compressors

Warning: The compressors listed below have security issues and/or are no longer maintained. For information about the security of the various compressors, see the CompFuzz Results page.

  • csc 2016-10-13: May cause a segmentation fault when compiled with Apple LLVM version 7.3.0 (clang-703.0.31).
  • gipfeli 2016-07-13: Contains bugs causing decompression file mismatch when compiled with GCC 14.2 using -O3.
  • lzmat 1.01 v1.0: Contains decompression bugs and may cause a segmentation fault when compiled with GCC 4.9+ using -O3 optimization.
  • lzrw 15-Jul-1991: May trigger a segmentation fault when compiled with GCC 4.9+ using -O3.
  • wflz 2015-09-16: May result in a segmentation fault when compiled with GCC 4.9+ using -O3.
  • yalz77 2022-07-06: A segmentation fault was encountered with GCC 13.3.0 on a 32-bit ARM (arm-linux-gnueabi) target.
  • yappy 2014-03-22: A segmentation fault was observed with GCC 13.3.0 on a 32-bit ARM (arm-linux-gnueabi) system.

Benchmarks

The following results were obtained using lzbench 2.0.1, built with gcc 14.2.0 and executed with the options -eALL -t8,8 -o1c4. The tests were run on a single thread of an AMD EPYC 9554 processor at 3.10 GHz, with the CPU governor set to performance and turbo boost disabled for stability. The operating system was Ubuntu 24.04.1, and the benchmark made use of silesia.tar, which contains tarred files from the Silesia compression corpus.

The results sorted by ratio are available here.

Compressor nameCompressionDecompress.Compr. sizeRatio
memcpy16332 MB/s16362 MB/s211947520100.00
brieflz 1.3.0 -1199 MB/s354 MB/s8113880338.28
brieflz 1.3.0 -3132 MB/s364 MB/s7555073635.65
brieflz 1.3.0 -621.0 MB/s395 MB/s6720842031.71
brieflz 1.3.0 -82.84 MB/s419 MB/s6453171830.45
brotli 1.1.0 -0341 MB/s352 MB/s7843329837.01
brotli 1.1.0 -2140 MB/s413 MB/s6806948932.12
brotli 1.1.0 -537.1 MB/s451 MB/s5955544628.10
brotli 1.1.0 -812.3 MB/s477 MB/s5714830426.96
brotli 1.1.0 -110.58 MB/s389 MB/s5040779523.78
bsc 3.3.5 -m0 -e116.6 MB/s24.1 MB/s4914336623.19
bsc 3.3.5 -m4 -e131.2 MB/s14.3 MB/s5062697423.89
bsc 3.3.5 -m5 -e128.8 MB/s13.3 MB/s4952250423.37
bzip2 1.0.8 -114.8 MB/s46.6 MB/s6048481328.54
bzip2 1.0.8 -514.0 MB/s40.0 MB/s5572439526.29
bzip2 1.0.8 -913.1 MB/s37.5 MB/s5457281125.75
crush 1.0 -064.3 MB/s357 MB/s7306460334.47
crush 1.0 -16.95 MB/s407 MB/s6649441231.37
crush 1.0 -20.91 MB/s421 MB/s6374622330.08
fastlz 0.5.0 -1285 MB/s710 MB/s10462808449.37
fastlz 0.5.0 -2293 MB/s699 MB/s10090607247.61
fastlzma2 1.0.1 -121.9 MB/s75.8 MB/s5903095027.85
fastlzma2 1.0.1 -312.1 MB/s81.4 MB/s5402383325.49
fastlzma2 1.0.1 -57.31 MB/s87.6 MB/s5120956724.16
fastlzma2 1.0.1 -84.46 MB/s89.7 MB/s4912673623.18
fastlzma2 1.0.1 -103.31 MB/s90.2 MB/s4866606122.96
kanzi 2.3 -2155 MB/s432 MB/s6826430432.21
kanzi 2.3 -3106 MB/s321 MB/s6496386430.65
kanzi 2.3 -453.7 MB/s152 MB/s6076720128.67
kanzi 2.3 -521.0 MB/s50.3 MB/s5405046325.50
kanzi 2.3 -615.8 MB/s29.6 MB/s4951756823.36
kanzi 2.3 -710.2 MB/s15.2 MB/s4730820522.32
kanzi 2.3 -83.45 MB/s3.29 MB/s4324714920.40
kanzi 2.3 -92.44 MB/s2.35 MB/s4180765219.73
libdeflate 1.23 -1207 MB/s860 MB/s7350279134.68
libdeflate 1.23 -3136 MB/s895 MB/s7017081633.11
libdeflate 1.23 -684.3 MB/s912 MB/s6751061531.85
libdeflate 1.23 -928.5 MB/s904 MB/s6671575131.48
libdeflate 1.23 -125.14 MB/s919 MB/s6467872330.52
lizard 2.1 -10482 MB/s2172 MB/s10340297148.79
lizard 2.1 -12165 MB/s2014 MB/s8623242240.69
lizard 2.1 -1577.9 MB/s2119 MB/s8118733038.31
lizard 2.1 -194.74 MB/s1999 MB/s7741640036.53
lizard 2.1 -20387 MB/s1688 MB/s9692420445.73
lizard 2.1 -22162 MB/s1721 MB/s8486672540.04
lizard 2.1 -2521.9 MB/s1750 MB/s7513128635.45
lizard 2.1 -292.10 MB/s1819 MB/s6869422732.41
lizard 2.1 -30363 MB/s1187 MB/s8572742940.45
lizard 2.1 -32164 MB/s1276 MB/s7865265437.11
lizard 2.1 -3585.4 MB/s1548 MB/s7456358335.18
lizard 2.1 -394.52 MB/s1515 MB/s6980752232.94
lizard 2.1 -40297 MB/s1150 MB/s8084304938.14
lizard 2.1 -42141 MB/s1235 MB/s7335098834.61
lizard 2.1 -4521.6 MB/s1350 MB/s6667665331.46
lizard 2.1 -492.06 MB/s1325 MB/s6067921528.63
lz4fast 1.10.0 -171002 MB/s4166 MB/s13173280262.15
lz4fast 1.10.0 -9820 MB/s3922 MB/s12013079656.68
lz4fast 1.10.0 -3657 MB/s3744 MB/s10706619050.52
lz4 1.10.0577 MB/s3716 MB/s10088080047.60
lz4hc 1.10.0 -1262 MB/s3221 MB/s8913542942.06
lz4hc 1.10.0 -476.3 MB/s3421 MB/s7980790937.65
lz4hc 1.10.0 -930.9 MB/s3527 MB/s7788444836.75
lz4hc 1.10.0 -1210.5 MB/s3616 MB/s7726262036.45
lzav 4.5 -1385 MB/s2643 MB/s8649760940.81
lzav 4.5 -274.1 MB/s2574 MB/s7560266135.67
lzf 3.6 -0339 MB/s625 MB/s10568208849.86
lzf 3.6 -1339 MB/s637 MB/s10204109248.14
lzfse 2017-03-0881.3 MB/s724 MB/s6762428131.91
lzg 1.0.10 -185.9 MB/s524 MB/s10855366751.22
lzg 1.0.10 -447.8 MB/s528 MB/s9593055145.26
lzg 1.0.10 -628.6 MB/s562 MB/s8949022042.22
lzg 1.0.10 -88.97 MB/s611 MB/s8360690139.45
lzham 1.0 -d26 -011.7 MB/s233 MB/s6408987030.24
lzham 1.0 -d26 -13.08 MB/s309 MB/s5474058925.83
lzlib 1.15 -034.1 MB/s58.6 MB/s6384738630.12
lzlib 1.15 -37.69 MB/s66.9 MB/s5632067426.57
lzlib 1.15 -62.91 MB/s72.0 MB/s4977749523.49
lzlib 1.15 -91.81 MB/s72.5 MB/s4829688922.79
lzma 24.09 -031.0 MB/s74.1 MB/s6050982628.55
lzma 24.09 -222.4 MB/s83.1 MB/s5707249826.93
lzma 24.09 -412.6 MB/s85.6 MB/s5592636326.39
lzma 24.09 -64.86 MB/s91.5 MB/s4954491523.38
lzma 24.09 -94.01 MB/s93.0 MB/s4867497322.97
lzo1 2.10 -1236 MB/s647 MB/s10647451950.24
lzo1 2.10 -99106 MB/s682 MB/s9494612944.80
lzo1a 2.10 -1234 MB/s696 MB/s10420225149.16
lzo1a 2.10 -99106 MB/s722 MB/s9266626543.72
lzo1b 2.10 -1201 MB/s642 MB/s9703608745.78
lzo1b 2.10 -3206 MB/s658 MB/s9404457844.37
lzo1b 2.10 -6205 MB/s659 MB/s9138235543.12
lzo1b 2.10 -9158 MB/s655 MB/s8926188442.12
lzo1b 2.10 -99104 MB/s664 MB/s8565337640.41
lzo1b 2.10 -99913.4 MB/s752 MB/s7659429236.14
lzo1c 2.10 -1209 MB/s671 MB/s9955090446.97
lzo1c 2.10 -3207 MB/s685 MB/s9671615345.63
lzo1c 2.10 -6173 MB/s681 MB/s9330362344.02
lzo1c 2.10 -9141 MB/s676 MB/s9104038642.95
lzo1c 2.10 -99102 MB/s682 MB/s8811228841.57
lzo1c 2.10 -99920.7 MB/s726 MB/s8039674137.93
lzo1f 2.10 -1185 MB/s633 MB/s9974332947.06
lzo1f 2.10 -99918.9 MB/s656 MB/s8089020638.17
lzo1x 2.10 -1513 MB/s696 MB/s10057253747.45
lzo1x 2.10 -11560 MB/s710 MB/s10660462950.30
lzo1x 2.10 -12545 MB/s695 MB/s10323885948.71
lzo1x 2.10 -15532 MB/s694 MB/s10146209447.87
lzo1x 2.10 -9997.13 MB/s658 MB/s7530190335.53
lzo1y 2.10 -1514 MB/s689 MB/s10125831847.78
lzo1y 2.10 -9997.37 MB/s647 MB/s7550384935.62
lzo1z 2.10 -9997.22 MB/s643 MB/s7506133135.42
lzo2a 2.10 -99923.8 MB/s531 MB/s8280933739.07
lzsse2 2019-04-18 -119.0 MB/s3286 MB/s8797609541.51
lzsse2 2019-04-18 -68.18 MB/s3786 MB/s7583710135.78
lzsse2 2019-04-18 -127.97 MB/s3790 MB/s7582997335.78
lzsse2 2019-04-18 -168.00 MB/s3788 MB/s7582997335.78
lzsse4 2019-04-18 -117.8 MB/s4209 MB/s8254210638.94
lzsse4 2019-04-18 -69.10 MB/s4598 MB/s7611829835.91
lzsse4 2019-04-18 -128.89 MB/s4611 MB/s7611301735.91
lzsse4 2019-04-18 -168.90 MB/s4611 MB/s7611301735.91
lzsse8 2019-04-18 -116.4 MB/s4340 MB/s8186624538.63
lzsse8 2019-04-18 -68.70 MB/s4752 MB/s7546971735.61
lzsse8 2019-04-18 -128.53 MB/s4761 MB/s7546433935.61
lzsse8 2019-04-18 -168.52 MB/s4755 MB/s7546433935.61
lzvn 2017-03-0869.3 MB/s884 MB/s8081460938.13
ppmd8 24.09 -413.2 MB/s12.0 MB/s5124193224.18
quicklz 1.5.0 -1459 MB/s491 MB/s9472056244.69
quicklz 1.5.0 -2223 MB/s485 MB/s8455562739.89
quicklz 1.5.0 -360.2 MB/s835 MB/s8182224138.60
slz_gzip 1.2.1 -1310 MB/s354 MB/s9965794647.02
slz_gzip 1.2.1 -2303 MB/s356 MB/s9686308245.70
slz_gzip 1.2.1 -3297 MB/s357 MB/s9618776845.38
snappy 1.2.1401 MB/s1077 MB/s10141544347.85
tornado 0.6a -1351 MB/s499 MB/s10738184650.66
tornado 0.6a -2298 MB/s458 MB/s9007666042.50
tornado 0.6a -3185 MB/s283 MB/s7266204434.28
tornado 0.6a -4154 MB/s296 MB/s7051361733.27
tornado 0.6a -570.9 MB/s232 MB/s6412960430.26
tornado 0.6a -645.6 MB/s230 MB/s6236458329.42
tornado 0.6a -716.9 MB/s223 MB/s5902632527.85
tornado 0.6a -105.58 MB/s228 MB/s5758824127.17
tornado 0.6a -135.42 MB/s243 MB/s5561407226.24
tornado 0.6a -162.32 MB/s255 MB/s5325704625.13
ucl_nrv2b 1.03 -148.5 MB/s290 MB/s8170316838.55
ucl_nrv2b 1.03 -618.2 MB/s332 MB/s7390218534.87
ucl_nrv2b 1.03 -92.05 MB/s363 MB/s7103119533.51
ucl_nrv2d 1.03 -148.8 MB/s293 MB/s8146197638.43
ucl_nrv2d 1.03 -618.1 MB/s333 MB/s7375767334.80
ucl_nrv2d 1.03 -92.06 MB/s364 MB/s7005389533.05
ucl_nrv2e 1.03 -149.0 MB/s297 MB/s8119556038.31
ucl_nrv2e 1.03 -618.1 MB/s342 MB/s7330201234.58
ucl_nrv2e 1.03 -92.06 MB/s372 MB/s6964513432.86
xz 5.6.3 -023.6 MB/s98.2 MB/s6257943529.53
xz 5.6.3 -37.52 MB/s122 MB/s5574512526.30
xz 5.6.3 -62.97 MB/s127 MB/s4919592923.21
xz 5.6.3 -92.57 MB/s123 MB/s4874530623.00
zlib 1.3.1 -193.0 MB/s323 MB/s7725902936.45
zlib 1.3.1 -625.3 MB/s344 MB/s6822843132.19
zlib 1.3.1 -910.3 MB/s348 MB/s6764454831.92
zlib-ng 2.2.3 -1202 MB/s471 MB/s9412704744.41
zlib-ng 2.2.3 -662.1 MB/s509 MB/s6886112932.49
zlib-ng 2.2.3 -924.6 MB/s518 MB/s6758206031.89
zling 2018-10-12 -078.5 MB/s178 MB/s6299059029.72
zling 2018-10-12 -170.0 MB/s182 MB/s6202254629.26
zling 2018-10-12 -263.1 MB/s184 MB/s6150309329.02
zling 2018-10-12 -356.6 MB/s186 MB/s6099982828.78
zling 2018-10-12 -447.9 MB/s187 MB/s6062676828.60
zstd_fast 1.5.6 --5573 MB/s1950 MB/s10309375248.64
zstd_fast 1.5.6 --3518 MB/s1822 MB/s9467467244.67
zstd_fast 1.5.6 --1459 MB/s1717 MB/s8698400941.04
zstd 1.5.6 -1422 MB/s1347 MB/s7342191434.64
zstd 1.5.6 -2344 MB/s1246 MB/s6950344432.79
zstd 1.5.6 -5125 MB/s1197 MB/s6304031029.74
zstd 1.5.6 -862.9 MB/s1319 MB/s6001506428.32
zstd 1.5.6 -1134.4 MB/s1332 MB/s5826229927.49
zstd 1.5.6 -158.36 MB/s1369 MB/s5716883426.97
zstd 1.5.6 -183.79 MB/s1169 MB/s5332987325.16
zstd 1.5.6 -222.08 MB/s1073 MB/s5233388024.69