Jul 20, 2023

In-memory benchmark of open-source LZ77/LZSS/LZMA compressors

lzbench is an in-memory benchmark of open-source LZ77/LZSS/LZMA compressors. It joins all compressors into a single executable. At the beginning, an input file is read to memory. Then all compressors are used to compress and decompress the file and decompressed file is verified.

This approach has a big advantage of using the same compiler with the same optimizations for all compressors. The disadvantage is that it requires source code of each compressor therefore Slug or lzturbo are not included.

LZBench is a software utility that belongs to the FreeBSD ports benchmarks category. It is an in-memory benchmark that compares the performance of several lossless compression algorithms. It has a software framework that allows you to add additional compressors quite easily. LZBench can be particularly useful to developers, system administrators, or even general FreeBSD users who are looking to optimize storage or transmission of large amounts of data.

In this article, we will dive deeper into understanding the working of LZBench, the benefits of using it, and a step-by-step guide on how to install and use LZBench in the FreeBSD environment.


The process for installing the LZBench port is pretty straightforward. You will first need to navigate to the /usr/ports/benchmarks/lzbench/ directory and then execute the make install clean command, as shown below

cd /usr/ports/benchmarks/lzbench/
make install clean


After successfully installing LZBench, using it is just a matter of executing it with the required flags and parameters. Below is a list of some basic flags that you can use with LZBench

  • -e specifies the list of compressors to benchmark. You can list multiple compressors in comma-separated format.
  • -t specifies the time in seconds to test each compressor. The default time is 1 second. A longer period will produce more accurate results.
  • -oX sets the compression level to X. The default compression level is 3.
  • -i specifies the number of iterations for each test. The default is 1 iteration.
  • -m specifies whether to use multi-threaded compression if available.

Here is an example command

lzbench -ezstd,lz4,snappy -t5 -o3 -i10 -m filename

This command will run a benchmark on the ‘filename’ file using the Zstd, LZ4, and Snappy compressors. Each test will last 5 seconds, the compression level will be set to 3, there will be 10 iterations of the test, and multi-threaded compression will be utilized if available.

Benefits of LZBench

The benefits of using LZBench in the FreeBSD operating system are multifaceted. Here are just a few

  • Selection of Compressors LZBench supports a broad range of compression algorithms including but not limited to Gzip, Snappy, LZ4, Zstandard, and Brotli. This gives you a wide selection to choose from based on your specific needs.

  • Flexibility With LZBench, you can easily customize the testing process based on the options and flags provided. This makes it ideal for any sort of benchmark testing, whether simple or complex.

  • Multi-Threaded Testing LZBench supports multithreading. This means it can simultaneously test multiple processors if they are available, providing a more comprehensive and efficient benchmark testing mechanism.

  • Comparison Feature Public testing results can be directly compared to results from LZBench tests. This allows users to make informed decisions based on actual performance results rather than theoretical ones.


LZBench is a highly useful benchmarking tool in the FreeBSD environment. We recommend FreeBSD users to integrate this port into their regular workflow, especially those who are constantly dealing with large amounts of data.

Do remember that for any FreeBSD system or network, security is paramount. Therefore, consider checking out the [nmap]https//freebsdsoftware.org/security/nmap.html port on FreeBSD as well. Nmap is a highly granular IT security scanner that can help in diagnosing possible network vulnerabilities in real-time, complementing your efforts to optimize and secure your FreeBSD systems.

Happy computing with FreeBSD!

Checkout these related ports:
  • Wrk - Modern HTTP benchmarking tool
  • Webbench - Simple forking web benchmark
  • Vkpeak - Profile Vulkan devices to find their peak capacities
  • Vkoverhead - Evaluate CPU overhead of Vulkan drivers
  • Vkmark - Vulkan benchmark
  • Vegeta - HTTP load testing tool and library
  • Uperf - Network performance tool to model and replay of networking patterns
  • Unixbench - BYTE magazine's Public Domain benchmark for UNIX
  • Uica - Code Analyzer from the uops.info project
  • Ubench - Unix Benchmark Utility for CPU(s) and memory
  • Typometer - Text/code editor typing latency analyzer
  • Ttcp - Benchmarking tool for analysing TCP and UDP performance
  • Tsung - Multi-protocol distributed load testing tool
  • Thrulay - Network capacity tester
  • Tcpblast - Measures the throughput of a TCP connection