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

Avoid OrderBy.ToArray/ToList overheads for length 1#99639

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
stephentoub merged 1 commit intodotnet:mainfromstephentoub:orderby1
Mar 15, 2024

Conversation

@stephentoub
Copy link
Member

We already special-case length 0. That can trivially be extended to length 1.

usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Running;BenchmarkSwitcher.FromAssembly(typeof(Tests).Assembly).Run(args);[MemoryDiagnoser(false)][HideColumns("Job","Error","StdDev","Median","RatioSD")]publicclassTests{privateIEnumerable<string>_data;[Params(1)]publicintCount{get;set;}[GlobalSetup]publicvoidSetup()=>_data=Enumerable.Range(0,Count).Select(i=>i.ToString());[Benchmark]publicstring[]OrderArray()=>_data.Order().ToArray();[Benchmark]publicList<string>OrderList()=>_data.Order().ToList();}
MethodToolchainCountMeanRatioAllocatedAlloc Ratio
OrderArray\main\corerun.exe185.30 ns1.00336 B1.00
OrderArray\pr\corerun.exe133.53 ns0.39120 B0.36
OrderList\main\corerun.exe191.46 ns1.00392 B1.00
OrderList\pr\corerun.exe142.60 ns0.47184 B0.47

PaulusParssinen reacted with rocket emoji
We already special-case length 0. That can trivially be extended to length 1.
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-linq
See info inarea-owners.md if you want to be subscribed.

@stephentoubstephentoub merged commit084c9db intodotnet:mainMar 15, 2024
@stephentoubstephentoub deleted the orderby1 branchMarch 15, 2024 16:03
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 15, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@eiriktsarpaliseiriktsarpaliseiriktsarpalis approved these changes

+1 more reviewer

@MichalPetrykaMichalPetrykaMichalPetryka left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

@stephentoubstephentoub

Projects

None yet

Milestone

9.0.0

Development

Successfully merging this pull request may close these issues.

3 participants

@stephentoub@eiriktsarpalis@MichalPetryka

[8]ページ先頭

©2009-2025 Movatter.jp