From 77d44019c69db9f84ee4a7f8da7fa557374be38e Mon Sep 17 00:00:00 2001 From: Melnik Alexander Date: Sat, 29 Sep 2018 13:57:02 +0300 Subject: [PATCH] Update readme --- README.md | 34 ++++++++----------- .../Standart.Hash.xxHash.csproj | 3 ++ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 4878278..79c0371 100644 --- a/README.md +++ b/README.md @@ -46,33 +46,25 @@ This benchmark was launched on a **Windows 10 (10.0.16299.309)**. The reference ## Comparison between ะก# and C implementation -| Method | Language | 1KB Time | 1MB Time | 1GB Time | -|--------|---------:|----------:|----------:|----------:| -| Hash32 | C# | 185.1 ns | 170.6 us | 193.6 ms | -| Hash32 | C | 183.5 ns | 170.1 us | 190.8 ms | -| Hash64 | C# | 117.3 ns | 87.1 us | 116.9 ms | -| Hash64 | C | 104.8 ns | 85.3 us | 114.1 ms | +| Method | Platform | Language | 1KB Time | 1MB Time | 1GB Time | Speed | Difference | +|--------|---------:|---------:|----------:|----------:|----------:|----------:|-----------:| +| Hash32 | x64 | C# | 185.1 ns | 170.6 us | 193.6 ms | 5.16 GB/s | 1.4 % | +| Hash32 | x64 | C | 183.5 ns | 170.1 us | 190.8 ms | 5.16 GB/s | 1.4 % | +| Hash64 | x64 | C# | 117.3 ns | 87.1 us | 116.9 ms | 5.16 GB/s | 2.4 % | +| Hash64 | x64 | C | 104.8 ns | 85.3 us | 114.1 ms | 5.16 GB/s | 2.4 % | -## Defference - -| Method | Platform | Language | Size | Time | Speed | Difference | -|--------|---------:|---------:|-----:|----------:|----------:|-----------:| -| Hash32 | x64 | C# | 1GB | 193.6 ms | 5.16 GB/s | 1.4 % | -| Hash32 | x64 | C | 1GB | 190.8 ms | 5.24 GB/s | 1.4 % | -| Hash64 | x64 | C# | 1GB | 116.9 ms | 8.55 GB/s | 2.4 % | -| Hash64 | x64 | C | 1GB | 114.1 ms | 8.76 GB/s | 2.4 % | ## Api ```cs public static uint ComputeHash(byte[] data, int length, uint seed = 0) { throw null; } public static uint ComputeHash(Span data, int length, uint seed = 0) { throw null; } public static uint ComputeHash(Stream stream, int bufferSize = 4096, uint seed = 0) { throw null; } -public static async Task ComputeHashAsync(Stream stream, int bufferSize = 4096, uint seed = 0) { throw null; } +public static async ValueTask ComputeHashAsync(Stream stream, int bufferSize = 4096, uint seed = 0) { throw null; } public static ulong ComputeHash(byte[] data, int length, ulong seed = 0) { throw null; } public static ulong ComputeHash(Span data, int length, ulong seed = 0) { throw null; } public static ulong ComputeHash(Stream stream, int bufferSize = 8192, ulong seed = 0) { throw null; } -public static async Task ComputeHashAsync(Stream stream, int bufferSize = 8192, ulong seed = 0) { throw null; } +public static async ValueTask ComputeHashAsync(Stream stream, int bufferSize = 8192, ulong seed = 0) { throw null; } ``` ## Examples @@ -81,12 +73,14 @@ A few examples of how to use api byte[] data = Encoding.UTF8.GetBytes("veni vidi vici"); ulong h64_1 = xxHash64.ComputeHash(data, data.Length); -ulong h64_2 = xxHash64.ComputeHash(new MemoryStream(data)); -ulong h64_3 = await xxHash64.ComputeHashAsync(new MemoryStream(data)); +ulong h64_2 = xxHash64.ComputeHash(new Span(data), data.Length); +ulong h64_3 = xxHash64.ComputeHash(new MemoryStream(data)); +ulong h64_4 = await xxHash64.ComputeHashAsync(new MemoryStream(data)); uint h32_1 = xxHash32.ComputeHash(data, data.Length); -uint h32_2 = xxHash32.ComputeHash(new MemoryStream(data)); -uint h32_3 = await xxHash32.ComputeHashAsync(new MemoryStream(data)); +uint h32_2 = xxHash32.ComputeHash(new Span(data), data.Length); +uint h32_3 = xxHash32.ComputeHash(new MemoryStream(data)); +uint h32_4 = await xxHash32.ComputeHashAsync(new MemoryStream(data)); ``` ---

diff --git a/src/Standart.Hash.xxHash/Standart.Hash.xxHash.csproj b/src/Standart.Hash.xxHash/Standart.Hash.xxHash.csproj index 5e797e4..5c204bc 100644 --- a/src/Standart.Hash.xxHash/Standart.Hash.xxHash.csproj +++ b/src/Standart.Hash.xxHash/Standart.Hash.xxHash.csproj @@ -17,4 +17,7 @@ + + netstandard2.0 + \ No newline at end of file