-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Marvin #114
Marvin #114
Conversation
public void Setup() => _string = new string(Enumerable.Repeat('a', BytesCount / (sizeof(char)/ sizeof(byte))).ToArray()); | ||
|
||
[Benchmark] | ||
public int ComputeHash() => _string.GetHashCode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the benchmark here would be System.Hashing.ComputeHash
. Would it make more sense to be called GetHashCode instead? Or something more descriptive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that GetHashCode
method exists in the base class (object
) so we would need to override the GetHashCode
method and the benchmark would include the virtual method invocation cost.
I was also trying to find better class name, but:
- I can't call it Marvin because such type exists, and for .NET and .NET Core 2.0- the implementation was not Marvin algo.
- The
HashCode
name is taken by existing type
I am open to better ideas, I just run out of name ideas ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like System.Hashing.GetDefaultStringHashCode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe GetStringHashCode
?
Fixes #44
The original CoreFX benchmarks have it's own copy of Marvin and benchmark the copy. Which needs to be kept in sync manually. I think that we should avoid that.
As @ViktorHofer explained this was because the Marvin class is internal and to make it public we would need to go through API review.
IMHO the best we can do right now is to benchmark
string.GetHashCode
which is just a call toMarvin.ComputeHash
.It also allows us to compare
string.GetHashCode
for .NET and .NET Core, where due to security reasons we have regressed the performance https://github.com/dotnet/corefx/issues/30994@jorive @ViktorHofer what do you think?
dotnet run -c Release -f netcoreapp2.1 -- -f *Hashing* --clr --core21 --join