-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The benchmark shows that
HashCode
is faster than murmurhash3:
``` | Method | N | Mean | Error | StdDev | |----------- |------ |-----------:|--------:|--------:| | MurmurHash | 1000 | 209.1 ns | 0.11 ns | 0.11 ns | | HashCode | 1000 | 133.8 ns | 0.18 ns | 0.17 ns | | MurmurHash | 10000 | 2,117.4 ns | 2.74 ns | 2.43 ns | | HashCode | 10000 | 1,349.3 ns | 2.95 ns | 2.62 ns | ``` Based on this removed MurmurHash3.cs entirely and replaced all uses with `HashCode`.
- Loading branch information
1 parent
f43421a
commit 945a3c8
Showing
4 changed files
with
29 additions
and
107 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace Arch.Core.Extensions.Internal; | ||
|
||
internal static class HashCodeExtensions | ||
{ | ||
#if !NET5_0_OR_GREATER | ||
public static void AddBytes(ref this HashCode hashCode, ReadOnlySpan<byte> bytes) | ||
{ | ||
for (int i = 0; i < bytes.Length; i++) | ||
{ | ||
hashCode.Add(bytes[i]); | ||
} | ||
} | ||
#endif | ||
|
||
public static void AddSpan<T>(ref this HashCode hashCode, ReadOnlySpan<T> items) | ||
where T : unmanaged | ||
{ | ||
hashCode.AddBytes(MemoryMarshal.AsBytes(items)); | ||
} | ||
|
||
public static void AddSpan<T>(ref this HashCode hashCode, Span<T> items) | ||
where T : unmanaged | ||
{ | ||
hashCode.AddBytes(MemoryMarshal.AsBytes(items)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.