Skip to content
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

Merged
merged 3 commits into from
Aug 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/benchmarks/corefx/System/Hashing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Linq;
using BenchmarkDotNet.Attributes;

namespace System
{
public class Hashing
{
private string _string;

[Params(10, 100, 1_000, 10_000)]
public int BytesCount;

/// <summary>
/// Marvin is internal, this is why we call string.GetHashCode to measure it's performance
/// see https://github.com/dotnet/corefx/blob/8252ecc2eb0da08cd474a303b646e111d74d2a71/src/Common/src/CoreLib/System/String.Comparison.cs#L749
/// </summary>
[GlobalSetup]
public void Setup() => _string = new string(Enumerable.Repeat('a', BytesCount / (sizeof(char)/ sizeof(byte))).ToArray());

[Benchmark]
public int GetStringHashCode() => _string.GetHashCode();
}
}