Skip to content

Commit

Permalink
added CH.Crc32 to comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
force-net committed Jun 19, 2016
1 parent 96fa9e0 commit d25a6f2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Crc32.NET.Tests/Crc32.NET.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="CH.Crc32">
<HintPath>..\packages\CH.Crc32.1.0\lib\net40\CH.Crc32.dll</HintPath>
</Reference>
<Reference Include="Crc32, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Crc32.1.0.0\lib\net40\Crc32.dll</HintPath>
Expand Down
20 changes: 20 additions & 0 deletions Crc32.NET.Tests/PerformanceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,28 @@

namespace Force.Crc32.Tests
{
[TestFixture]
public class PerformanceTest
{
[Test]
public void ThroughputCHCrc32_By_tanglebones()
{
var data = new byte[65536];
var random = new Random();
random.NextBytes(data);
long total = 0;
var stopwatch = new Stopwatch();
stopwatch.Start();
while (stopwatch.Elapsed < TimeSpan.FromSeconds(3))
{
CH.Crc32.Crc.Crc32(data);
total += data.Length;
}

stopwatch.Stop();
Console.WriteLine("Throughput: {0:0.0} MB/s", total / stopwatch.Elapsed.TotalSeconds / 1024 / 1024);
}

[Test]
public void ThroughputCrc32_By_dariogriffo()
{
Expand Down
2 changes: 2 additions & 0 deletions Crc32.NET.Tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public static void Main()
{
var pt = new PerformanceTest();
pt.ThroughputCrc32_By_dariogriffo();
pt.ThroughputCHCrc32_By_tanglebones();
pt.ThroughputCrc32_By_Data_HashFunction_Crc();
pt.ThroughputCrc32_By_Me();
}
}
Expand Down
1 change: 1 addition & 0 deletions Crc32.NET.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CH.Crc32" version="1.0" targetFramework="net40" />
<package id="Crc32" version="1.0.0" targetFramework="net40" />
<package id="NUnit" version="2.6.4" targetFramework="net20" />
<package id="System.Data.HashFunction.Core" version="1.8.2.2" targetFramework="net40" />
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

Optimized and fast implementation of Crc32 algorithm in pure .NET.

*(But if you need, I can native implementation which is twice faster .NET version)*
*(But if you need, I can add native implementation which is twice faster .NET version with transparent .net wrapper)*

This library is port of [Crc32C.NET](https://crc32c.angeloflogic.com/) by Robert Važan but for Crc32 algorithm.

If you did not catch the difference, it is *C* (Castagnoli). I recommend to use Crc32C, not usual CRC32, because it is faster (up to 20GB/s) and slightly better in error detection. But if you need exactly Crc32, this library is the best choice.
If you do not not catch the difference, it is *C* (Castagnoli). I recommend to use Crc32C, not usual CRC32, because it is faster (up to 20GB/s) and slightly better in error detection. But if you need exactly Crc32, this library is the best choice.

### Performance

Library | Speed
--------|-------
[CH.Crc32](https://github.com/tanglebones/ch-crc32) by Cliff Hammerschmidt | 117 MB/s
[Crc32](https://github.com/dariogriffo/Crc32) by Dario Griffo | 382 MB/s
[Data.HashFunction.CRC](https://github.com/brandondahler/Data.HashFunction/) by Brandon Dahler | 203 MB/s
This library | **1066** MB/s
[Data.HashFunction.CRC](https://github.com/brandondahler/Data.HashFunction/) by Brandon Dahler | 206 MB/s
This library | **1078** MB/s

## Some notes

Expand Down

0 comments on commit d25a6f2

Please sign in to comment.