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

Add BinaryWriter perf tests #1639

Merged
merged 2 commits into from
Jan 29, 2021
Merged

Conversation

GrabYourPitchforks
Copy link
Member

Adds benchmarks for various BinaryWriter.Write APIs.

@GrabYourPitchforks
Copy link
Member Author

/cc @adamsitnik

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @GrabYourPitchforks !

{
/// <summary>
/// A <see cref="Stream"/> that acts as a null sink for data. Overrides members that
/// <see cref="Stream.Null"/> does not. Used for benchmarking wrappers around Stream
Copy link
Member

@adamsitnik adamsitnik Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for adding a clear explanation why Stream.Null is not enough 👍


public override void WriteByte(byte value) { }

#if NETCOREAPP2_1_OR_GREATER // these virtual methods only exist in .NET Core 2.1+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is something new to me. Are you sure that it works outside of dotnet/runtime? cc @ViktorHofer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@terrajobst Aren't these defines part of the latest compilers? In theory they should work in any project type in any repo, even non-MSFT code.

private char[] _inputAsChars;
private BinaryWriter _bw;

[Params(4, 16, 512, 10_000, 100_000, 500_000, 2_000_000)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we reduce the number of test cases to the number of different code paths? https://github.com/dotnet/performance/blob/master/docs/microbenchmark-design-guidelines.md#Code-Paths

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, there should be 3 different code paths. How about 32 chars, 8k chars, and 2M chars?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about 32 chars, 8k chars, and 2M chars?

👍

@GrabYourPitchforks
Copy link
Member Author

BTW I'm not quite sure how to debug the CI failures. Looks like a .nupkg dependency is missing in one of the legs?

@billwert
Copy link
Member

CI is a real mess right now for a bunch of reasons, not the least of which today is that there's been Nuget outages. Don't worry about it.

@adamsitnik adamsitnik merged commit e0d77ab into dotnet:master Jan 29, 2021
@GrabYourPitchforks GrabYourPitchforks deleted the binarywriter branch January 29, 2021 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants