Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Override Read(Span)/ReadByte on PipeReaderStream#55086

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
adamsitnik merged 1 commit intodotnet:mainfromstephentoub:pipelinesreadbyte
Jul 8, 2021

Conversation

@stephentoub
Copy link
Member

We can do better than the base implementations for reading. For writing, there's not a lot we can do better than the base.

Fixes#53692
cc:@halter73

MethodToolchainMeanRatioAllocated
ReadByte\main\corerun.exe542,053.1 ns1.00131,072 B
ReadByte\pr\corerun.exe423,396.2 ns0.780 B
ReadSpan\main\corerun.exe459.7 ns1.0072 B
ReadSpan\pr\corerun.exe309.6 ns0.670 B
usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Columns;usingBenchmarkDotNet.Configs;usingBenchmarkDotNet.Diagnosers;usingBenchmarkDotNet.Reports;usingBenchmarkDotNet.Running;usingPerfolizer.Horology;usingSystem;usingSystem.Globalization;usingSystem.IO;usingSystem.IO.Pipelines;[MemoryDiagnoser]publicclassProgram{publicstaticvoidMain(string[]args)=>BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args,DefaultConfig.Instance.WithSummaryStyle(newSummaryStyle(CultureInfo.InvariantCulture,printUnitsInHeader:false,sizeUnit:SizeUnit.B,timeUnit:TimeUnit.Nanosecond,printZeroValuesInContent:true)));constintLength=4096;privateStream_writer,_reader;privatebyte[]_buffer=newbyte[Length];publicProgram(){varpipe=newPipe();_writer=pipe.Writer.AsStream();_reader=pipe.Reader.AsStream();}[Benchmark]publicvoidReadByte(){_writer.WriteAsync(_buffer).GetAwaiter().GetResult();for(inti=0;i<Length;i++){_reader.ReadByte();}}[Benchmark]publicvoidReadSpan(){_writer.WriteAsync(_buffer).GetAwaiter().GetResult();Span<byte>buffer=_buffer;while(!buffer.IsEmpty){buffer=buffer.Slice(_reader.Read(buffer));}}}

manandre reacted with thumbs up emoji
We can do better than the base implementations for reading.  For writing, there's not a lot we can do better than the base.
@adamsitnikadamsitnik added the tenet-performancePerformance related issue labelJul 8, 2021
Copy link
Member

@adamsitnikadamsitnik left a comment

Choose a reason for hiding this comment

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

LGTM, that is a very nice improvement!

@adamsitnikadamsitnik merged commit1ca17cd intodotnet:mainJul 8, 2021
@adamsitnikadamsitnik added this to the6.0.0 milestoneJul 8, 2021
@stephentoubstephentoub deleted the pipelinesreadbyte branchJuly 8, 2021 13:29
@ghostghost locked asresolvedand limited conversation to collaboratorsAug 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@adamsitnikadamsitnikadamsitnik approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

6.0.0

Development

Successfully merging this pull request may close these issues.

Override more methods in PipeReaderStream and PipeWriterStream

2 participants

@stephentoub@adamsitnik

[8]ページ先頭

©2009-2025 Movatter.jp