From 5a3fa2af6f6cfcfef79d763b08be7abd1c0cf633 Mon Sep 17 00:00:00 2001 From: Brant Burnett Date: Sun, 22 Dec 2024 20:40:37 -0500 Subject: [PATCH] Misc documentation and code coverage improvements --- README.md | 8 ++++---- Snappier/Internal/SnappyCompressor.cs | 2 ++ Snappier/Snappy.cs | 4 ++-- index.md | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 28f5488..6288f5a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Snappier is a pure C# port of Google's [Snappy](https://github.com/google/snappy) compression algorithm. It is designed with speed as the primary goal, rather than compression ratio, and is ideal for compressing network traffic. Please see [the Snappy README file](https://github.com/google/snappy/blob/master/README.md) for more details on Snappy. -Complete documentation is available at (https://brantburnett.github.io/Snappier/). +Complete documentation is available at https://brantburnett.github.io/Snappier/. ## Project Goals @@ -15,7 +15,7 @@ The Snappier project aims to meet the following needs of the .NET community. - Use .NET paradigms, including asynchronous stream support - Full compatibility with both block and stream formats - Near C++ level performance - - Note: This is only possible on .NET 6 and later with the aid of [Span<T>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1?view=netcore-3.1) and [System.Runtime.Intrinsics](https://fiigii.com/2019/03/03/Hardware-intrinsic-in-NET-Core-3-0-Introduction/). + - Note: This is only possible on .NET 6 and later with the aid of [Span<T>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1?view=net-9.0) and [System.Runtime.Intrinsics](https://devblogs.microsoft.com/dotnet/dotnet-8-hardware-intrinsics/) - .NET 4.6.1 is the slowest - Keep allocations and garbage collection to a minimum using buffer pools @@ -111,5 +111,5 @@ public class Program There are other projects available for C#/.NET which implement Snappy compression. -- [Snappy.NET](https://snappy.machinezoo.com/) - Uses P/Invoke to C++ for great performance. However, it only works on Windows, and is a bit heap allocation heavy in some cases. It also hasn't been updated since 2014 (as of 10/2020). This project may still be the best choice if your project is on the legacy .NET Framework on Windows, where Snappier is much less performant. -- [IronSnappy](https://github.com/aloneguid/IronSnappy) - Another pure C# port, based on the Golang implementation instead of the C++ implementation. +- [Snappy.NET](https://snappy.machinezoo.com/) - Uses P/Invoke to C++ for great performance. However, it only works on Windows, is a bit heap allocation heavy in some cases, and is a deprecated project. This project may still be the best choice if your project is on the legacy .NET Framework on Windows, where Snappier is much less performant. +- [IronSnappy](https://www.nuget.org/packages/IronSnappy) - Another pure C# port, based on the Golang implementation instead of the C++ implementation. diff --git a/Snappier/Internal/SnappyCompressor.cs b/Snappier/Internal/SnappyCompressor.cs index 664b80d..4086a2a 100644 --- a/Snappier/Internal/SnappyCompressor.cs +++ b/Snappier/Internal/SnappyCompressor.cs @@ -1,6 +1,7 @@ using System; using System.Buffers; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace Snappier.Internal @@ -10,6 +11,7 @@ internal class SnappyCompressor : IDisposable private HashTable? _workingMemory = new(); [Obsolete("Retained for benchmark comparisons to previous versions")] + [ExcludeFromCodeCoverage] public int Compress(ReadOnlySpan input, Span output) { if (!TryCompress(input, output, out int bytesWritten)) diff --git a/Snappier/Snappy.cs b/Snappier/Snappy.cs index 4fd078a..378a461 100644 --- a/Snappier/Snappy.cs +++ b/Snappier/Snappy.cs @@ -219,7 +219,7 @@ public static void Decompress(ReadOnlySequence input, IBufferWriter } /// - /// Decompress a block of Snappy to a new memory buffer. This must be an entire block. + /// Decompress a block of Snappy data to a new memory buffer. This must be an entire block. /// /// Data to decompress. /// An with the decompressed data. The caller is responsible for disposing this object. @@ -242,7 +242,7 @@ public static IMemoryOwner DecompressToMemory(ReadOnlySpan input) } /// - /// Decompress a block of Snappy to a new memory buffer. This must be an entire block. + /// Decompress a block of Snappy data to a new memory buffer. This must be an entire block. /// /// Data to decompress. /// An with the decompressed data. The caller is responsible for disposing this object. diff --git a/index.md b/index.md index 4bc03c9..e28b0c1 100644 --- a/index.md +++ b/index.md @@ -15,7 +15,7 @@ The Snappier project aims to meet the following needs of the .NET community. - Use .NET paradigms, including asynchronous stream support - Full compatibility with both block and stream formats - Near C++ level performance - - Note: This is only possible on .NET 6 and later with the aid of [Span<T>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1?view=netcore-3.1) and [System.Runtime.Intrinsics](https://fiigii.com/2019/03/03/Hardware-intrinsic-in-NET-Core-3-0-Introduction/). + - Note: This is only possible on .NET 6 and later with the aid of [Span<T>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1?view=net-9.0) and [System.Runtime.Intrinsics](https://devblogs.microsoft.com/dotnet/dotnet-8-hardware-intrinsics/) - .NET 4.6.1 is the slowest - Keep allocations and garbage collection to a minimum using buffer pools