GithubHelp home page GithubHelp logo

zstdsharp's Introduction

ZstdSharp

NuGet package

ZstdSharp is a port of zstd compression library to С#
Based on Zstandard v1.5.2
Supports .NET Core 3.1, .NET 5, .NET 6, .NET Standard 2.0+, .NET Framework 4.6.1+

Usage

ZstdSharp has an unsafe API much the same as zstd.
There are also safe wrappers.

Compress:

var src = File.ReadAllBytes("dickens");
using var compressor = new Compressor(level);
var compressed = compressor.Wrap(src);

Decompress:

var src = File.ReadAllBytes("dickens.zst");
using var decompressor = new Decompressor();
var decompressed = decompressor.Unwrap(src);

Benchmark

Best performance is achieved on .NET Core. System.Runtime.Intrinsics namespace is required for hardware accelerated bit and vector operations. .NET Standard and .NET Framework will use software implementation

Comparision zstd (native) and ZstdSharp

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.1566 (21H2)
12th Gen Intel Core i7-12700, 1 CPU, 20 logical and 12 physical cores
.NET SDK=6.0.200
  [Host]     : .NET 6.0.2 (6.0.222.6406), X64 RyuJIT
  DefaultJob : .NET 6.0.2 (6.0.222.6406), X64 RyuJIT

Compression level 1

Method Mean Error StdDev Ratio InstructionRetired/Op
CompressNative 25.565 ms 0.2983 ms 0.2491 ms 1.00 397,370,833
CompressSharp 35.616 ms 0.0593 ms 0.0495 ms 1.39 523,222,222
DecompressNative 6.821 ms 0.0097 ms 0.0086 ms 1.00 154,583,333
DecompressSharp 8.178 ms 0.0198 ms 0.0176 ms 1.20 184,807,292

Compression level 5

Method Mean Error StdDev Ratio RatioSD InstructionRetired/Op
CompressNative 79.408 ms 0.1196 ms 0.0933 ms 1.00 0.00 1,096,971,429
CompressSharp 96.018 ms 0.3943 ms 0.3292 ms 1.21 0.00 1,528,277,778
DecompressNative 8.156 ms 0.1620 ms 0.1663 ms 1.00 0.00 205,591,912
DecompressSharp 10.637 ms 0.0937 ms 0.0831 ms 1.31 0.03 250,476,042

zstdsharp's People

Contributors

2a5f avatar cheavyarms avatar oleg-st avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.