Skip to content

Add BinaryWriter perf tests#1639

Merged
adamsitnik merged 2 commits into
dotnet:masterfrom
GrabYourPitchforks:binarywriter
Jan 29, 2021
Merged

Add BinaryWriter perf tests#1639
adamsitnik merged 2 commits into
dotnet:masterfrom
GrabYourPitchforks:binarywriter

Conversation

@GrabYourPitchforks

Copy link
Copy Markdown
Member

Adds benchmarks for various BinaryWriter.Write APIs.

@GrabYourPitchforks

Copy link
Copy Markdown
Member Author

/cc @adamsitnik

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member

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

@adamsitnik adamsitnik Jan 28, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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.

Comment thread src/benchmarks/micro/libraries/System.IO/NullWriteStream.cs Outdated
private char[] _inputAsChars;
private BinaryWriter _bw;

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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