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

Optimize Enumerable.OfType with custom iterator#99216

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 5 commits intodotnet:mainfromstephentoub:oftypeiterator
Mar 5, 2024

Conversation

stephentoub
Copy link
Member

MethodToolchainTargetMeanRatioAllocatedAlloc Ratio
OfTypeForEach\main\corerun.exeObject112.64 ns1.0088 B1.00
OfTypeForEach\pr\corerun.exeObject66.18 ns0.5980 B0.91
OfTypeCount\main\corerun.exeObject119.40 ns1.0088 B1.00
OfTypeCount\pr\corerun.exeObject101.25 ns0.8580 B0.91
OfTypeToArray\main\corerun.exeObject207.82 ns1.00160 B1.00
OfTypeToArray\pr\corerun.exeObject129.60 ns0.62152 B0.95
OfTypeToList\main\corerun.exeObject214.81 ns1.00264 B1.00
OfTypeToList\pr\corerun.exeObject158.42 ns0.74256 B0.97
OfTypeFirst\main\corerun.exeObject46.60 ns1.0088 B1.00
OfTypeFirst\pr\corerun.exeObject47.11 ns1.0180 B0.91
OfTypeLast\main\corerun.exeObject146.69 ns1.0088 B1.00
OfTypeLast\pr\corerun.exeObject72.18 ns0.4980 B0.91
OfTypeSelectForEach\main\corerun.exeObject172.42 ns1.00144 B1.00
OfTypeSelectForEach\pr\corerun.exeObject84.93 ns0.49104 B0.72
OfTypeForEach\main\corerun.exeString2,175.93 ns1.0088 B1.00
OfTypeForEach\pr\corerun.exeString1,046.87 ns0.4880 B0.91
OfTypeCount\main\corerun.exeString2,065.02 ns1.0088 B1.00
OfTypeCount\pr\corerun.exeString974.42 ns0.4780 B0.91
OfTypeToArray\main\corerun.exeString3,289.18 ns1.001432 B1.00
OfTypeToArray\pr\corerun.exeString4,942.53 ns1.501424 B0.99
OfTypeToList\main\corerun.exeString4,016.68 ns1.004352 B1.00
OfTypeToList\pr\corerun.exeString2,926.28 ns0.734344 B1.00
OfTypeFirst\main\corerun.exeString44.71 ns1.0088 B1.00
OfTypeFirst\pr\corerun.exeString31.20 ns0.7080 B0.91
OfTypeLast\main\corerun.exeString2,226.84 ns1.0088 B1.00
OfTypeLast\pr\corerun.exeString1,339.43 ns0.5980 B0.91
OfTypeSelectForEach\main\corerun.exeString2,689.61 ns1.00144 B1.00
OfTypeSelectForEach\pr\corerun.exeString1,150.00 ns0.43104 B0.72
usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Running;usingSystem.Reflection;BenchmarkSwitcher.FromAssembly(typeof(Tests).Assembly).Run(args);[MemoryDiagnoser(false)][HideColumns("Job","Error","StdDev","Median","RatioSD")]publicpartialclassTests{privateIEnumerable<MemberInfo>_members;[Params(typeof(object),typeof(string))]publicTypeTarget{get;set;}[GlobalSetup]publicvoidSetup()=>_members=Target.GetMembers();[Benchmark]publicintOfTypeForEach(){intsum=0;foreach(MethodInfomemberin_members.OfType<MethodInfo>()){sum+=member.Name.Length;}returnsum;}[Benchmark]publicintOfTypeCount()=>_members.OfType<MethodInfo>().Count();[Benchmark]publicMethodInfo[]OfTypeToArray()=>_members.OfType<MethodInfo>().ToArray();[Benchmark]publicList<MethodInfo>OfTypeToList()=>_members.OfType<MethodInfo>().ToList();[Benchmark]publicMethodInfoOfTypeFirst()=>_members.OfType<MethodInfo>().First();[Benchmark]publicMethodInfoOfTypeLast()=>_members.OfType<MethodInfo>().Last();[Benchmark]publicintOfTypeSelectForEach(){intsum=0;foreach(stringnamein_members.OfType<MethodInfo>().Select(m=>m.Name)){sum+=name.Length;}returnsum;}}

ShreyasJejurkar and TonyValenti reacted with rocket emoji
@stephentoubstephentoub added area-System.Linq tenet-performancePerformance related issue labelsMar 4, 2024
@stephentoubstephentoub added this to the9.0.0 milestoneMar 4, 2024
@ghost
Copy link

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

Issue Details
MethodToolchainTargetMeanRatioAllocatedAlloc Ratio
OfTypeForEach\main\corerun.exeObject112.64 ns1.0088 B1.00
OfTypeForEach\pr\corerun.exeObject66.18 ns0.5980 B0.91
OfTypeCount\main\corerun.exeObject119.40 ns1.0088 B1.00
OfTypeCount\pr\corerun.exeObject101.25 ns0.8580 B0.91
OfTypeToArray\main\corerun.exeObject207.82 ns1.00160 B1.00
OfTypeToArray\pr\corerun.exeObject129.60 ns0.62152 B0.95
OfTypeToList\main\corerun.exeObject214.81 ns1.00264 B1.00
OfTypeToList\pr\corerun.exeObject158.42 ns0.74256 B0.97
OfTypeFirst\main\corerun.exeObject46.60 ns1.0088 B1.00
OfTypeFirst\pr\corerun.exeObject47.11 ns1.0180 B0.91
OfTypeLast\main\corerun.exeObject146.69 ns1.0088 B1.00
OfTypeLast\pr\corerun.exeObject72.18 ns0.4980 B0.91
OfTypeSelectForEach\main\corerun.exeObject172.42 ns1.00144 B1.00
OfTypeSelectForEach\pr\corerun.exeObject84.93 ns0.49104 B0.72
OfTypeForEach\main\corerun.exeString2,175.93 ns1.0088 B1.00
OfTypeForEach\pr\corerun.exeString1,046.87 ns0.4880 B0.91
OfTypeCount\main\corerun.exeString2,065.02 ns1.0088 B1.00
OfTypeCount\pr\corerun.exeString974.42 ns0.4780 B0.91
OfTypeToArray\main\corerun.exeString3,289.18 ns1.001432 B1.00
OfTypeToArray\pr\corerun.exeString4,942.53 ns1.501424 B0.99
OfTypeToList\main\corerun.exeString4,016.68 ns1.004352 B1.00
OfTypeToList\pr\corerun.exeString2,926.28 ns0.734344 B1.00
OfTypeFirst\main\corerun.exeString44.71 ns1.0088 B1.00
OfTypeFirst\pr\corerun.exeString31.20 ns0.7080 B0.91
OfTypeLast\main\corerun.exeString2,226.84 ns1.0088 B1.00
OfTypeLast\pr\corerun.exeString1,339.43 ns0.5980 B0.91
OfTypeSelectForEach\main\corerun.exeString2,689.61 ns1.00144 B1.00
OfTypeSelectForEach\pr\corerun.exeString1,150.00 ns0.43104 B0.72
usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Running;usingSystem.Reflection;BenchmarkSwitcher.FromAssembly(typeof(Tests).Assembly).Run(args);[MemoryDiagnoser(false)][HideColumns("Job","Error","StdDev","Median","RatioSD")]publicpartialclassTests{privateIEnumerable<MemberInfo>_members;[Params(typeof(object),typeof(string))]publicTypeTarget{get;set;}[GlobalSetup]publicvoidSetup()=>_members=Target.GetMembers();[Benchmark]publicintOfTypeForEach(){intsum=0;foreach(MethodInfomemberin_members.OfType<MethodInfo>()){sum+=member.Name.Length;}returnsum;}[Benchmark]publicintOfTypeCount()=>_members.OfType<MethodInfo>().Count();[Benchmark]publicMethodInfo[]OfTypeToArray()=>_members.OfType<MethodInfo>().ToArray();[Benchmark]publicList<MethodInfo>OfTypeToList()=>_members.OfType<MethodInfo>().ToList();[Benchmark]publicMethodInfoOfTypeFirst()=>_members.OfType<MethodInfo>().First();[Benchmark]publicMethodInfoOfTypeLast()=>_members.OfType<MethodInfo>().Last();[Benchmark]publicintOfTypeSelectForEach(){intsum=0;foreach(stringnamein_members.OfType<MethodInfo>().Select(m=>m.Name)){sum+=name.Length;}returnsum;}}
Author:stephentoub
Assignees:-
Labels:

area-System.Linq,tenet-performance

Milestone:9.0.0

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@eiriktsarpaliseiriktsarpaliseiriktsarpalis approved these changes

Assignees

@stephentoubstephentoub

Labels
area-System.Linqtenet-performancePerformance related issue
Projects
None yet
Milestone
9.0.0
Development

Successfully merging this pull request may close these issues.

2 participants
@stephentoub@eiriktsarpalis

[8]ページ先頭

©2009-2025 Movatter.jp