Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
E

EasyCompressor

> 数据库
Open source

⚡An Easy-to-Use and Optimized compression library for .NET that unified several compression algorithms including LZ4, Snappy, Zstd, LZMA, Brotli, GZip, ZLib, an

386 stars0 likes0 views
WebsiteGitHub

About

⚡An Easy-to-Use and Optimized compression library for .NET that unified several compression algorithms including LZ4, Snappy, Zstd, LZMA, Brotli, GZip, ZLib, an

EasyCompressor

An Easy-to-Use and Optimized compression library for .NET that unified several compression algorithms including LZ4, Snappy, Zstd, LZMA, Brotli, GZip, ZLib, and Deflate.

Along with a great Performance Benchmark between different compression algorithms.

This library aids in Improving Performance by Reducing Memory Usage and Bandwidth Usage. (see How)

  • Usage
  • Features
  • Nuget Packages
  • Get Started
    • Using New Instance or the Shared Instance
    • Using Dependency Injection
    • Using Named Instances
  • Benchmarks
    • Best Compressors based on Overall Performance (Speed and Memory Allocation) in each case
    • Best Compressors based on Highest compression (Smallest size)
  • What's Changed from v1.4.0 to v2.0.2
  • Todo

Usage

  • Compress your BLOB data for Archiving and Saving the Storage (on average from 30% to 90%)
  • Compress your Caching objects for Saving the Memory Usage (it also has a nice integration with EasyCaching)
  • Reduce the Bandwidth Usage of your network by reducing the volume of data sent or received. (see How)
  • Improve the Performance of your I/O Operations like Service-to-Service Communication. (see How)

Features

  • Offers a range of compression algorithms, including LZ4, Snappy, Zstd, LZMA, Brotli, GZip, ZLib, and Deflate.
  • Support for async/await operations with support of CancellationToken.
  • Stream operations are fully supported.
  • Optimized and implemented with a focus on performance.

Note

The default comparison levels are carefully configured based on extensive benchmarking to ensure the highest level of efficiency and speed at a reasonable compression ratio.

Improving Data Transfer Speed by Sending/Receiving Less

Compression/Decompression has overhead but it reduces the size of your data, which can potentially result in faster transfer times, even when accounting for the additional time required for compression and decompression.

When a file is compressed, it becomes smaller in size, which means it requires less bandwidth to transfer. If the compression ratio is significant, the reduced file size can compensate for the extra time needed for compression and decompression.

For example, let's say you have an uncompressed file that takes 10 seconds to transfer. If you compress this file using a fast compressor like LZ4, Snappy, or Zstd, the compression time might be around 1 second. However, the compressed file size is significantly smaller, let's say it's only 20% of the original size. Now, when you transfer the compressed file, it will only take 2 seconds (20% of the original transfer time). In this scenario, the total time (compression time + transfer time) would be 3 seconds (1 second for compression + 2 seconds for transfer), which is less than the original 10 seconds it would have taken to transfer the uncompressed file.

It's important to note that the actual time savings will depend on various factors, such as the compression ratio achieved, the speed of the compression and decompression algorithms, the network bandwidth, and other system-specific considerations. However, with fast compressors like LZ4, Snappy, or Zstd and significant compression ratios, it is possible to achieve overall time savings when transferring compressed files compared to transferring uncompressed files.

Nuget Packages

Package Description
EasyCompressor Including Algorithms :
  • Brotli (Highest compression ratio - the Smallest size) (Only available in .NETCoreApp2.1, .NETStandard2.1 and above)
  • GZip
  • Deflate
  • ZLib (Only available in .NET6.0 and above) | EasyCompressor.LZ4⭐️ | Algorithm: LZ4 Extremely Fast (Recommended - see Benchmarks) | EasyCompressor.Snappier⭐️ | Algorithm: Snappy Extremely Fast (Recommended - see Benchmarks) | EasyCompressor.ZstdSharp⭐️ | Algorithm: Zstd (Zstandard) Extremely Fast (Recommended - see Benchmarks) | EasyCompressor.LZMA | Algorithm: LZMA High compression ratio (small size) but very Slow (Not recommended - see Benchmarks) | EasyCompressor.Zstd (deprecated) | Instead, use EasyCompressor.ZstdSharp. | EasyCompressor.Snappy (deprecated) | Instead, use EasyCompressor.Snappier | EasyCompressor.BrotliNET (deprecated) | Instead, use BrotliCompressor in EasyCompressor itself (base package) (Use only if your project targets .NETFramework462 and above or .NETCoreApp2.0) | EasyCaching.Extensions.EasyCompressor⭐️ | A winning combination by integrating with EasyCaching to compress your cache data. (Recommended) See How to use

Note :

All of these packages are cross-platform except EasyCompressor.Zstd and EasyCompressor.Snappy which are not cross-platform because their underlying library are just a wrapper around the native dlls only for windows.

Get Started

1. Install Package

bash
PM> Install-Package EasyCompressor.LZ4

PM> # Install-Package EasyCompressor (for Brotli, GZip, Deflate, ZLib)
PM> # Install-Package EasyCompressor.Snappier
PM> # Install-Package EasyCompressor.ZstdSharp
PM> # Install-Package EasyCompressor.LZMA
PM> # Install-Package EasyCompressor.Zstd (deprecated)
PM> # Install-Package EasyCompressor.Snappy (deprecated)
PM> # Install-Package EasyCompressor.BrotliNET (deprecated)

2. Using New Instance or the Shared Instance

…

3. Using Dependency Injection

Add Services

…

Inject/Resolve it and use it

…

4. Using Named Instances

Register Named compressors

…

Resolve it using ICompressorProvider

csharp
using EasyCompressor;

public class YourClass
{
    private readonly ICompressor _lz4Compressor;
    private readonly ICompressor _snappierCompressor;
    private readonly ICompressor _zstdsharpCompressor;

    public YourClass(ICompressorProvider compressorProvider)
    {
        _lz4Compressor = compressorProvider.GetCompressor("lz4");
        _snappierCompressor = compressorProvider.GetCompressor("snappier");
        _zstdsharpCompressor = compressor.GetCompressor("zstdsharp");
    }
}

Benchmarks

To view the Full benchmark, visit this HTML Page.

Other Benchmarks

Compressing/Decompressing Binary Data (byte[])

  • Comparison in terms of Speed (Mean/Execution Time) (visit it's HTML or Image)
  • Comparison in terms of Memory Usage (Allocation Size) (visit it's HTML or Image)

Compressing/Decompressing Stream Data

  • Comparison in terms of Speed (Mean/Execution Time) (visit it's HTML or Image)
  • Comparison in terms of Memory Usage (Allocation Size) (visit it's HTML or Image)

Compressing/Decompressing Stream Data (Async)

  • Comparison in terms of Speed (Mean/Execution Time) (visit it's HTML or Image)
  • Comparison in terms of Memory Usage (Allocation Size) (visit it's HTML or Image)

Key Results and Conclusion

Best Compressors based on Overall Performance (Speed and Memory Allocation) in each case

Operation Binary Stream StreamAsync
Compress SnappierCompressor
LZ4Compressor
ZstdSharpCompressor SnappierCompressor
LZ4Compressor
BrotliCompressor LZ4Compressor
BrotliCompressor

| Decompress | LZ4Compressor SnappierCompressor ZstdSharpCompressor | SnappierCompressor LZ4Compressor ZstdSharpCompressor | ZstdSharpCompressor LZ4Compressor

Best Compressors based on Highest compression (Smallest size)

  1. BrotliCompressor (smaller in medium/small data with moderate speed and memory usage)
  2. LZMACompressor (smaller in large data but very slow and memory inefficient)
  3. ZstdSharpCompressor (fastest meanwhile with acceptable/good enough level of compression)

BenchmarkDotNetVisualizer

All the benchmarks are visualized using BenchmarkDotNetVisualizer.

What's Changed from v1.4.0 to v2.0.2

  • Many improvements were made including performance optimizations and bug fixes.
  • A great Performance Benchmark between different compression algorithms added.
  • Two new compressors added: EasyCompressor.Snappier and EasyCompressor.ZstdSharp
  • Shared instances added to each compressor for Ease-of-Use LZ4Compressor.Shared.Compress(bytes);
  • EasyCompressor.Zstd bug fixed and the latest version of zstd.dll (v1.5.5) was included in the package.
  • These packages deprecated: EasyCompressor.Zstd, EasyCompressor.Snappy and EasyCompressor.BrotliNET because their development has been stopped and newer and better packages have replaced them.
  • The default compression levels have changed and are carefully configured based on extensive benchmarking to ensure the highest level of efficiency and speed at a reasonable compression ratio.
  • **Three new LZ4 bin

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#benchmarkbenchmarkingbrotlicompress

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库