DrewScoggins / performance-2

This repo contains benchmarks used for testing the performance of all .NET Runtimes
MIT License
0 stars 0 forks source link

[Perf] Changes at 3/15/2021 3:42:26 AM #4485

Open performanceautofiler[bot] opened 3 years ago

performanceautofiler[bot] commented 3 years ago

Run Information

Architecture x86
OS Windows 10.0.18362
Baseline c156959c33e48651b4ebfb51c64de510aadfefb3
Compare 4a8ec1f8b264e39951131c7acb2947c4b5f9769e

Improvemnts in System.Linq.Tests.Perf_Enumerable

Benchmark Baseline Test Test/Base Baseline IR Compare IR IR Ratio Baseline ETL Compare ETL
[FirstWithPredicate_LastElementMatches](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.FirstWithPredicate_LastElementMatches(input%3a%20Array).html>) 738.02 ns 649.69 ns 0.88 Trace Trace
[ElementAt](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.ElementAt(input%3a%20IList).html>) 10.98 ns 9.31 ns 0.85 Trace Trace
[Select](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.Select(input%3a%20Array).html>) 767.92 ns 613.11 ns 0.80 Trace Trace
[SelectToArray](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.SelectToArray(input%3a%20List).html>) 314.89 ns 296.63 ns 0.94 Trace Trace
[Where](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.Where(input%3a%20IEnumerable).html>) 1.27 μs 1.12 μs 0.88 Trace Trace
[WhereSingle_LastElementMatches](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.WhereSingle_LastElementMatches(input%3a%20List).html>) 527.90 ns 463.94 ns 0.88 Trace Trace
[FirstWithPredicate_LastElementMatches](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.FirstWithPredicate_LastElementMatches(input%3a%20IEnumerable).html>) 741.38 ns 652.39 ns 0.88 Trace Trace
[CastToSameType](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.CastToSameType(input%3a%20IEnumerable).html>) 562.27 ns 496.27 ns 0.88 Trace Trace
[Contains_ElementNotFound](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.Contains_ElementNotFound(input%3a%20IEnumerable).html>) 588.99 ns 496.30 ns 0.84 Trace Trace
[Except](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.Except(input%3a%20IEnumerable).html>) 4.11 μs 3.59 μs 0.87 Trace Trace
[Prepend](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.Prepend(input%3a%20IEnumerable).html>) 3.20 μs 3.03 μs 0.95 Trace Trace
[Aggregate](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.Aggregate(input%3a%20IEnumerable).html>) 766.65 ns 673.40 ns 0.88 Trace Trace
[All_AllElementsMatch](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.All_AllElementsMatch(input%3a%20IEnumerable).html>) 821.84 ns 676.52 ns 0.82 Trace Trace
[Take_All](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.Take_All(input%3a%20IEnumerable).html>) 1.03 μs 935.99 ns 0.91 Trace Trace
[WhereFirst_LastElementMatches](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.WhereFirst_LastElementMatches(input%3a%20IEnumerable).html>) 825.27 ns 747.41 ns 0.91 Trace Trace
[WhereSingleOrDefault_LastElementMatches](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.WhereSingleOrDefault_LastElementMatches(input%3a%20List).html>) 583.99 ns 463.40 ns 0.79 Trace Trace
[WhereSingle_LastElementMatches](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.WhereSingle_LastElementMatches(input%3a%20IEnumerable).html>) 847.75 ns 686.81 ns 0.81 Trace Trace
[LastWithPredicate_FirstElementMatches](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.LastWithPredicate_FirstElementMatches(input%3a%20IList).html>) 16.58 ns 14.50 ns 0.87 Trace Trace
[Intersect](<https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/refs/heads/main_x86_Windows 10.0.18362/System.Linq.Tests.Perf_Enumerable.Intersect(input%3a%20IEnumerable).html>) 4.75 μs 4.17 μs 0.88 Trace Trace

graph graph graph graph graph graph graph graph graph graph graph graph graph graph graph graph graph graph graph Historical Data in Reporting System

Repro

git clone https://github.com/dotnet/performance.git
py .\performance\scripts\benchmarks_ci.py -f netcoreapp5.0 --filter 'System.Linq.Tests.Perf_Enumerable*'
. ### Payloads [Baseline]() [Compare]() ### Histogram #### System.Linq.Tests.Perf_Enumerable.FirstWithPredicate_LastElementMatches(input: Array) ```log [641.543 ; 670.001) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [670.001 ; 686.921) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [686.921 ; 706.047) | [706.047 ; 736.342) | @@@@@@@@@@@@@@@@@@ [736.342 ; 753.262) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [753.262 ; 782.308) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [782.308 ; 801.594) | @@@@@@@@@@@@@ [801.594 ; 840.079) | @@@@@@@@@@@@@@@@@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.FirstWithPredicate_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5514] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0B1C3388 lea edx,ds:[5514] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 81 ``` ```assembly ; System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push eax lea eax,[ebp+0FFFC] push eax call System.Linq.Enumerable.TryGetFirst[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2, Boolean ByRef) cmp byte ptr [ebp+0FFFC],0 je short M01_L00 mov esp,ebp pop ebp ret M01_L00: call System.Linq.ThrowHelper.ThrowNoMatchException() int 3 ; Total bytes of code 29 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.FirstWithPredicate_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[551C] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0AF633E8 lea edx,ds:[551C] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 81 ``` ```assembly ; System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push eax lea eax,[ebp+0FFFC] push eax call System.Linq.Enumerable.TryGetFirst[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2, Boolean ByRef) cmp byte ptr [ebp+0FFFC],0 je short M01_L00 mov esp,ebp pop ebp ret M01_L00: call System.Linq.ThrowHelper.ThrowNoMatchException() int 3 ; Total bytes of code 29 ``` #### System.Linq.Tests.Perf_Enumerable.ElementAt(input: IList) ```log [ 9.307 ; 9.577) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [ 9.577 ; 10.010) | [10.010 ; 10.281) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [10.281 ; 10.498) | @@@ [10.498 ; 10.768) | [10.768 ; 11.194) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [11.194 ; 11.552) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [11.552 ; 12.028) | @@@@@@@@@@@@@@@@@@@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.ElementAt(System.Linq.Tests.LinqTestData) mov ecx,[edx+4] mov edx,32 call System.Linq.Enumerable.ElementAt[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) ret ; Total bytes of code 14 ``` ```assembly ; System.Linq.Enumerable.ElementAt[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) push ebp mov ebp,esp push edi push esi sub esp,8 mov esi,ecx mov edi,edx test esi,esi je short M01_L03 mov edx,esi mov ecx,offset MT_System.Linq.IPartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax je short M01_L00 lea ecx,[ebp+0FFF4] push ecx mov ecx,eax mov edx,edi call dword ptr ds:[2A0] cmp byte ptr [ebp+0FFF4],0 je short M01_L02 lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M01_L00: mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax je short M01_L01 mov ecx,eax mov edx,edi call dword ptr ds:[29C] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M01_L01: lea ecx,[ebp+0FFF0] push ecx mov ecx,esi mov edx,edi call System.Linq.Enumerable.TryGetElement[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32, Int32 ByRef) test eax,eax je short M01_L02 mov eax,[ebp+0FFF0] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M01_L02: mov ecx,6 call System.Linq.ThrowHelper.ThrowArgumentOutOfRangeException(System.Linq.ExceptionArgument) int 3 M01_L03: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 141 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.ElementAt(System.Linq.Tests.LinqTestData) mov ecx,[edx+4] mov edx,32 call System.Linq.Enumerable.ElementAt[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) ret ; Total bytes of code 14 ``` ```assembly ; System.Linq.Enumerable.ElementAt[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) push ebp mov ebp,esp push edi push esi sub esp,8 mov esi,ecx mov edi,edx test esi,esi je short M01_L03 mov edx,esi mov ecx,offset MT_System.Linq.IPartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax je short M01_L00 lea ecx,[ebp+0FFF4] push ecx mov ecx,eax mov edx,edi call dword ptr ds:[294] cmp byte ptr [ebp+0FFF4],0 je short M01_L02 lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M01_L00: mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax je short M01_L01 mov ecx,eax mov edx,edi call dword ptr ds:[290] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M01_L01: lea ecx,[ebp+0FFF0] push ecx mov ecx,esi mov edx,edi call System.Linq.Enumerable.TryGetElement[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32, Int32 ByRef) test eax,eax je short M01_L02 mov eax,[ebp+0FFF0] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M01_L02: mov ecx,6 call System.Linq.ThrowHelper.ThrowArgumentOutOfRangeException(System.Linq.ExceptionArgument) int 3 M01_L03: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 141 ``` #### System.Linq.Tests.Perf_Enumerable.Select(input: Array) ```log [608.565 ; 622.359) | @@@@@@@@@@@@ [622.359 ; 637.209) | [637.209 ; 651.003) | @@@@@@ [651.003 ; 669.931) | [669.931 ; 683.725) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@ [683.725 ; 711.714) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [711.714 ; 734.664) | @@@@@ [734.664 ; 761.133) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [761.133 ; 784.621) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Select(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push edi push esi mov esi,ecx mov edi,[edx+4] mov edx,ds:[54FC] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0ABB3358 lea edx,ds:[54FC] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,edi call System.Linq.Enumerable.Select[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop edi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 95 ``` ```assembly ; System.Linq.Enumerable.Select[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx sub esp,8 xor eax,eax mov [ebp+0FFF0],eax mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L07 test edi,edi je near ptr M01_L08 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L00 push offset MD_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]].Select(System.Func`2) mov ecx,ebx mov edx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_VIRTUAL_FUNC_PTR mov ecx,ebx mov edx,edi call eax jmp near ptr M01_L06 M01_L00: mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov ebx,eax test ebx,ebx je near ptr M01_L04 mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY test eax,eax je short M01_L02 mov [ebp+0FFEC],eax cmp dword ptr [eax+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+SelectArrayIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] mov ebx,[ebp+0FFEC] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp near ptr M01_L06 M01_L01: mov ecx,0A2070C0 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1EE4] jmp near ptr M01_L06 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov esi,eax test esi,esi je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+SelectListIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx jmp short M01_L06 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+SelectIListIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L06 M01_L04: mov edx,esi mov ecx,offset MT_System.Linq.IPartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax je short M01_L05 xor ecx,ecx mov [ebp+0FFF0],ecx lea ecx,[ebp+0FFF0] push ecx mov ecx,edi mov edx,eax call System.Linq.Enumerable.CreateSelectIPartitionIterator[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Func`2, System.Linq.IPartition`1, System.Collections.Generic.IEnumerable`1 ByRef) cmp dword ptr [ebp+0FFF0],0 je short M01_L05 mov eax,[ebp+0FFF0] jmp short M01_L06 M01_L05: mov ecx,offset MT_System.Linq.Enumerable+SelectEnumerableIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L06: lea esp,[ebp+0FFF4] pop ebx pop esi pop edi pop ebp ret M01_L07: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L08: mov ecx,0F call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 409 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[284] mov [ebp+0FFE4],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[288] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[28C] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[288] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[290] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[290] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 105 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Select(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push edi push esi mov esi,ecx mov edi,[edx+4] mov edx,ds:[5504] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0AA833B8 lea edx,ds:[5504] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,edi call System.Linq.Enumerable.Select[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop edi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 95 ``` ```assembly ; System.Linq.Enumerable.Select[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx sub esp,8 xor eax,eax mov [ebp+0FFF0],eax mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L07 test edi,edi je near ptr M01_L08 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L00 push offset MD_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]].Select(System.Func`2) mov ecx,ebx mov edx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_VIRTUAL_FUNC_PTR mov ecx,ebx mov edx,edi call eax jmp near ptr M01_L06 M01_L00: mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov ebx,eax test ebx,ebx je near ptr M01_L04 mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY test eax,eax je short M01_L02 mov [ebp+0FFEC],eax cmp dword ptr [eax+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+SelectArrayIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] mov ebx,[ebp+0FFEC] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp near ptr M01_L06 M01_L01: mov ecx,0A0E6E90 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1EEC] jmp near ptr M01_L06 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov esi,eax test esi,esi je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+SelectListIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx jmp short M01_L06 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+SelectIListIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L06 M01_L04: mov edx,esi mov ecx,offset MT_System.Linq.IPartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax je short M01_L05 xor ecx,ecx mov [ebp+0FFF0],ecx lea ecx,[ebp+0FFF0] push ecx mov ecx,edi mov edx,eax call System.Linq.Enumerable.CreateSelectIPartitionIterator[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Func`2, System.Linq.IPartition`1, System.Collections.Generic.IEnumerable`1 ByRef) cmp dword ptr [ebp+0FFF0],0 je short M01_L05 mov eax,[ebp+0FFF0] jmp short M01_L06 M01_L05: mov ecx,offset MT_System.Linq.Enumerable+SelectEnumerableIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L06: lea esp,[ebp+0FFF4] pop ebx pop esi pop edi pop ebp ret M01_L07: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L08: mov ecx,0F call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 409 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[278] mov ecx,eax mov [ebp+0FFE4],ecx call dword ptr ds:[27C] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[280] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[27C] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[284] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[284] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 104 ``` #### System.Linq.Tests.Perf_Enumerable.SelectToArray(input: List) ```log [290.149 ; 298.645) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [298.645 ; 307.931) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [307.931 ; 318.810) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [318.810 ; 327.074) | @@@@@@@@@@@@@@@@@@@ [327.074 ; 338.876) | @@@@ [338.876 ; 357.308) | @@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.SelectToArray(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5548] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0B3035E0 lea edx,ds:[5548] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Select[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax call System.Linq.Enumerable.ToArray[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 88 ``` ```assembly ; System.Linq.Enumerable.Select[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx sub esp,8 xor eax,eax mov [ebp+0FFF0],eax mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L07 test edi,edi je near ptr M01_L08 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L00 push offset MD_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]].Select(System.Func`2) mov ecx,ebx mov edx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_VIRTUAL_FUNC_PTR mov ecx,ebx mov edx,edi call eax jmp near ptr M01_L06 M01_L00: mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov ebx,eax test ebx,ebx je near ptr M01_L04 mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY test eax,eax je short M01_L02 mov [ebp+0FFEC],eax cmp dword ptr [eax+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+SelectArrayIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] mov ebx,[ebp+0FFEC] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp near ptr M01_L06 M01_L01: mov ecx,0A9570C0 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1EFC] jmp near ptr M01_L06 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov esi,eax test esi,esi je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+SelectListIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx jmp short M01_L06 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+SelectIListIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L06 M01_L04: mov edx,esi mov ecx,offset MT_System.Linq.IPartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax je short M01_L05 xor ecx,ecx mov [ebp+0FFF0],ecx lea ecx,[ebp+0FFF0] push ecx mov ecx,edi mov edx,eax call System.Linq.Enumerable.CreateSelectIPartitionIterator[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Func`2, System.Linq.IPartition`1, System.Collections.Generic.IEnumerable`1 ByRef) cmp dword ptr [ebp+0FFF0],0 je short M01_L05 mov eax,[ebp+0FFF0] jmp short M01_L06 M01_L05: mov ecx,offset MT_System.Linq.Enumerable+SelectEnumerableIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L06: lea esp,[ebp+0FFF4] pop ebx pop esi pop edi pop ebp ret M01_L07: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L08: mov ecx,0F call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 409 ``` ```assembly ; System.Linq.Enumerable.ToArray[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp push esi mov esi,ecx test esi,esi je short M02_L01 mov edx,esi mov ecx,offset MT_System.Linq.IIListProvider`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax jne short M02_L00 mov ecx,esi call System.Collections.Generic.EnumerableHelpers.ToArray[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M02_L00: mov ecx,eax call dword ptr ds:[294] pop esi pop ebp ret M02_L01: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 58 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.SelectToArray(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5550] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0A523480 lea edx,ds:[5550] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Select[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax call System.Linq.Enumerable.ToArray[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 88 ``` ```assembly ; System.Linq.Enumerable.Select[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx sub esp,8 xor eax,eax mov [ebp+0FFF0],eax mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L07 test edi,edi je near ptr M01_L08 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L00 push offset MD_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]].Select(System.Func`2) mov ecx,ebx mov edx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_VIRTUAL_FUNC_PTR mov ecx,ebx mov edx,edi call eax jmp near ptr M01_L06 M01_L00: mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov ebx,eax test ebx,ebx je near ptr M01_L04 mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY test eax,eax je short M01_L02 mov [ebp+0FFEC],eax cmp dword ptr [eax+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+SelectArrayIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] mov ebx,[ebp+0FFEC] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp near ptr M01_L06 M01_L01: mov ecx,9B86E90 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1F04] jmp near ptr M01_L06 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov esi,eax test esi,esi je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+SelectListIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx jmp short M01_L06 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+SelectIListIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L06 M01_L04: mov edx,esi mov ecx,offset MT_System.Linq.IPartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax je short M01_L05 xor ecx,ecx mov [ebp+0FFF0],ecx lea ecx,[ebp+0FFF0] push ecx mov ecx,edi mov edx,eax call System.Linq.Enumerable.CreateSelectIPartitionIterator[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]](System.Func`2, System.Linq.IPartition`1, System.Collections.Generic.IEnumerable`1 ByRef) cmp dword ptr [ebp+0FFF0],0 je short M01_L05 mov eax,[ebp+0FFF0] jmp short M01_L06 M01_L05: mov ecx,offset MT_System.Linq.Enumerable+SelectEnumerableIterator`2[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L06: lea esp,[ebp+0FFF4] pop ebx pop esi pop edi pop ebp ret M01_L07: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L08: mov ecx,0F call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 409 ``` ```assembly ; System.Linq.Enumerable.ToArray[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp push esi mov esi,ecx test esi,esi je short M02_L01 mov edx,esi mov ecx,offset MT_System.Linq.IIListProvider`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax jne short M02_L00 mov ecx,esi call System.Collections.Generic.EnumerableHelpers.ToArray[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M02_L00: mov ecx,eax call dword ptr ds:[288] pop esi pop ebp ret M02_L01: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 58 ``` #### System.Linq.Tests.Perf_Enumerable.Where(input: IEnumerable) ```log [1106.621 ; 1137.808) | @@@@@@ [1137.808 ; 1171.741) | @@@ [1171.741 ; 1195.785) | [1195.785 ; 1231.902) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [1231.902 ; 1281.350) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [1281.350 ; 1321.300) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Where(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push edi push esi mov esi,ecx mov edi,[edx+4] mov edx,ds:[5500] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0B3D3360 lea edx,ds:[5500] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,edi call System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop edi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 95 ``` ```assembly ; System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L05 test edi,edi je near ptr M01_L06 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax je short M01_L00 mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+2C] call dword ptr [eax+8] jmp near ptr M01_L04 M01_L00: mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY mov ebx,eax test ebx,ebx je short M01_L02 cmp dword ptr [ebx+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+WhereArrayIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L01: mov ecx,0AA270C0 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1ED4] jmp short M01_L04 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L04: pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 268 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[284] mov [ebp+0FFE4],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[288] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[28C] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[288] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[290] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[290] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 105 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Where(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push edi push esi mov esi,ecx mov edi,[edx+4] mov edx,ds:[5508] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0A8833B0 lea edx,ds:[5508] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,edi call System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop edi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 95 ``` ```assembly ; System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L05 test edi,edi je near ptr M01_L06 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax je short M01_L00 mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+2C] call dword ptr [eax+8] jmp near ptr M01_L04 M01_L00: mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY mov ebx,eax test ebx,ebx je short M01_L02 cmp dword ptr [ebx+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+WhereArrayIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L01: mov ecx,9ED70B0 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1EDC] jmp short M01_L04 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L04: pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 268 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[278] mov ecx,eax mov [ebp+0FFE4],ecx call dword ptr ds:[27C] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[280] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[27C] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[284] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[284] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 104 ``` #### System.Linq.Tests.Perf_Enumerable.WhereSingle_LastElementMatches(input: List) ```log [431.221 ; 442.087) | @@@@@@@@@@@@@@@@@ [442.087 ; 453.605) | @ [453.605 ; 472.122) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [472.122 ; 484.382) | @@@@ [484.382 ; 498.080) | @@@ [498.080 ; 512.705) | @@@@@@ [512.705 ; 533.775) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [533.775 ; 548.427) | @@@@@@@@@@@@@@@@@@@@@@@@ [548.427 ; 567.512) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [567.512 ; 589.243) | [589.243 ; 610.974) | [610.974 ; 632.705) | [632.705 ; 652.419) | @ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.WhereSingle_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5528] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0A9733B0 lea edx,ds:[5528] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax call System.Linq.Enumerable.Single[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 88 ``` ```assembly ; System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L05 test edi,edi je near ptr M01_L06 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax je short M01_L00 mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+2C] call dword ptr [eax+8] jmp near ptr M01_L04 M01_L00: mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY mov ebx,eax test ebx,ebx je short M01_L02 cmp dword ptr [ebx+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+WhereArrayIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L01: mov ecx,9FD6EA0 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1ED0] jmp short M01_L04 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L04: pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 268 ``` ```assembly ; System.Linq.Enumerable.Single[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp push edi push esi sub esp,1C xor eax,eax mov [ebp+0FFDC],eax mov [ebp+0FFEC],eax mov esi,ecx test esi,esi je near ptr M02_L07 mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov edi,eax test edi,edi je short M02_L00 mov ecx,edi call dword ptr ds:[2C4] test eax,eax je near ptr M02_L08 cmp eax,1 jne near ptr M02_L09 mov ecx,edi xor edx,edx call dword ptr ds:[2C8] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L00: mov ecx,esi call dword ptr ds:[2B0] mov [ebp+0FFDC],eax mov ecx,[ebp+0FFDC] call dword ptr ds:[2B4] test eax,eax je short M02_L01 mov ecx,[ebp+0FFDC] call dword ptr ds:[2B8] mov esi,eax mov ecx,[ebp+0FFDC] call dword ptr ds:[2BC] test eax,eax jne short M02_L02 mov [ebp+0FFE0],esi mov dword ptr [ebp+0FFE8],0 mov dword ptr [ebp+0FFEC],0FC push offset M02_L03 jmp short M02_L04 M02_L01: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 M02_L02: mov ecx,[ebp+0FFDC] call dword ptr ds:[2C0] jmp short M02_L09 M02_L03: mov dword ptr [ebp+0FFEC],0 jmp short M02_L06 M02_L04: cmp dword ptr [ebp+0FFDC],0 je short M02_L05 mov ecx,[ebp+0FFDC] call dword ptr ds:[2C0] M02_L05: pop eax jmp eax M02_L06: mov eax,[ebp+0FFE0] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L07: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M02_L08: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 M02_L09: call System.Linq.ThrowHelper.ThrowMoreThanOneElementException() int 3 ; Total bytes of code 235 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.WhereSingle_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5530] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0ABA3410 lea edx,ds:[5530] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax call System.Linq.Enumerable.Single[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 88 ``` ```assembly ; System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L05 test edi,edi je near ptr M01_L06 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax je short M01_L00 mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+2C] call dword ptr [eax+8] jmp near ptr M01_L04 M01_L00: mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY mov ebx,eax test ebx,ebx je short M01_L02 cmp dword ptr [ebx+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+WhereArrayIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L01: mov ecx,0A206E90 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1ED8] jmp short M01_L04 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L04: pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 268 ``` ```assembly ; System.Linq.Enumerable.Single[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp push edi push esi sub esp,1C xor eax,eax mov [ebp+0FFDC],eax mov [ebp+0FFEC],eax mov esi,ecx test esi,esi je near ptr M02_L07 mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov edi,eax test edi,edi je short M02_L00 mov ecx,edi call dword ptr ds:[2B8] test eax,eax je near ptr M02_L08 cmp eax,1 jne near ptr M02_L09 mov ecx,edi xor edx,edx call dword ptr ds:[2BC] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L00: mov ecx,esi call dword ptr ds:[2A4] mov ecx,eax mov [ebp+0FFDC],ecx call dword ptr ds:[2A8] test eax,eax je short M02_L01 mov ecx,[ebp+0FFDC] call dword ptr ds:[2AC] mov esi,eax mov ecx,[ebp+0FFDC] call dword ptr ds:[2B0] test eax,eax jne short M02_L02 mov [ebp+0FFE0],esi mov dword ptr [ebp+0FFE8],0 mov dword ptr [ebp+0FFEC],0FC push offset M02_L03 jmp short M02_L04 M02_L01: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 M02_L02: mov ecx,[ebp+0FFDC] call dword ptr ds:[2B4] jmp short M02_L09 M02_L03: mov dword ptr [ebp+0FFEC],0 jmp short M02_L06 M02_L04: mov ecx,[ebp+0FFDC] test ecx,ecx je short M02_L05 call dword ptr ds:[2B4] mov ecx,[ebp+0FFDC] M02_L05: pop eax jmp eax M02_L06: mov eax,[ebp+0FFE0] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L07: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M02_L08: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 M02_L09: call System.Linq.ThrowHelper.ThrowMoreThanOneElementException() int 3 ; Total bytes of code 235 ``` #### System.Linq.Tests.Perf_Enumerable.FirstWithPredicate_LastElementMatches(input: IEnumerable) ```log [648.385 ; 664.457) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [664.457 ; 692.685) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [692.685 ; 707.681) | [707.681 ; 736.981) | @@@@@@@@@@@@@@@@ [736.981 ; 753.053) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [753.053 ; 769.154) | @@@@@ [769.154 ; 788.383) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [788.383 ; 805.110) | @@@@@@@@ [805.110 ; 837.052) | @@@@@@@@@@@@@@@@@@@@@@@@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.FirstWithPredicate_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5514] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0A773388 lea edx,ds:[5514] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 81 ``` ```assembly ; System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push eax lea eax,[ebp+0FFFC] push eax call System.Linq.Enumerable.TryGetFirst[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2, Boolean ByRef) cmp byte ptr [ebp+0FFFC],0 je short M01_L00 mov esp,ebp pop ebp ret M01_L00: call System.Linq.ThrowHelper.ThrowNoMatchException() int 3 ; Total bytes of code 29 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.FirstWithPredicate_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[551C] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0B0E33E8 lea edx,ds:[551C] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 81 ``` ```assembly ; System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push eax lea eax,[ebp+0FFFC] push eax call System.Linq.Enumerable.TryGetFirst[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2, Boolean ByRef) cmp byte ptr [ebp+0FFFC],0 je short M01_L00 mov esp,ebp pop ebp ret M01_L00: call System.Linq.ThrowHelper.ThrowNoMatchException() int 3 ; Total bytes of code 29 ``` #### System.Linq.Tests.Perf_Enumerable.CastToSameType(input: IEnumerable) ```log [435.481 ; 450.365) | @@@@@@ [450.365 ; 461.138) | [461.138 ; 476.022) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [476.022 ; 493.739) | @ [493.739 ; 508.623) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [508.623 ; 530.992) | @@@@@@@@@@@@@@@@@@@@@@@@@ [530.992 ; 545.876) | [545.876 ; 568.953) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [568.953 ; 584.884) | @ [584.884 ; 599.768) | @@@@@@@@@@@@@@@@@@@@@@@@@@ [599.768 ; 617.285) | @@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.CastToSameType(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,ecx mov ecx,[edx+4] call System.Linq.Enumerable.Cast[[System.Int32, System.Private.CoreLib]](System.Collections.IEnumerable) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop ebp ret ; Total bytes of code 27 ``` ```assembly ; System.Linq.Enumerable.Cast[[System.Int32, System.Private.CoreLib]](System.Collections.IEnumerable) push ebp mov ebp,esp push edi push esi mov esi,ecx mov edx,esi mov ecx,offset MT_System.Collections.Generic.IEnumerable`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFARRAY test eax,eax je short M01_L00 pop esi pop edi pop ebp ret M01_L00: test esi,esi je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+d__63`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov edi,eax mov dword ptr [edi+10],0FFFFFFFE call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [edi+18],eax lea edx,[edi+8] call CORINFO_HELP_ASSIGN_REF_ESI mov eax,edi pop esi pop edi pop ebp ret M01_L01: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 83 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[284] mov [ebp+0FFE4],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[288] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[28C] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[288] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[290] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[290] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 105 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.CastToSameType(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,ecx mov ecx,[edx+4] call System.Linq.Enumerable.Cast[[System.Int32, System.Private.CoreLib]](System.Collections.IEnumerable) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop ebp ret ; Total bytes of code 27 ``` ```assembly ; System.Linq.Enumerable.Cast[[System.Int32, System.Private.CoreLib]](System.Collections.IEnumerable) push ebp mov ebp,esp push edi push esi mov esi,ecx mov edx,esi mov ecx,offset MT_System.Collections.Generic.IEnumerable`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFARRAY test eax,eax je short M01_L00 pop esi pop edi pop ebp ret M01_L00: test esi,esi je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+d__63`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov edi,eax mov dword ptr [edi+10],0FFFFFFFE call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [edi+18],eax lea edx,[edi+8] call CORINFO_HELP_ASSIGN_REF_ESI mov eax,edi pop esi pop edi pop ebp ret M01_L01: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 83 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[278] mov ecx,eax mov [ebp+0FFE4],ecx call dword ptr ds:[27C] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[280] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[27C] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[284] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[284] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 104 ``` #### System.Linq.Tests.Perf_Enumerable.Contains_ElementNotFound(input: IEnumerable) ```log [488.430 ; 505.726) | @@@@@@@ [505.726 ; 516.394) | @@@@@@@@@@@@@@@@@ [516.394 ; 526.949) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [526.949 ; 537.873) | @@@@@@@ [537.873 ; 555.043) | [555.043 ; 578.029) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [578.029 ; 592.039) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [592.039 ; 604.819) | @@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Contains_ElementNotFound(System.Linq.Tests.LinqTestData) mov ecx,[edx+4] mov edx,65 call System.Linq.Enumerable.Contains[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) ret ; Total bytes of code 14 ``` ```assembly ; System.Linq.Enumerable.Contains[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) push ebp mov ebp,esp push edi push esi mov esi,ecx mov edi,edx mov edx,esi mov ecx,offset MT_System.Collections.Generic.ICollection`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax jne short M01_L00 push 0 mov ecx,esi mov edx,edi call System.Linq.Enumerable.Contains[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32, System.Collections.Generic.IEqualityComparer`1) pop esi pop edi pop ebp ret M01_L00: mov ecx,eax mov edx,edi call dword ptr ds:[2C4] pop esi pop edi pop ebp ret ; Total bytes of code 54 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Contains_ElementNotFound(System.Linq.Tests.LinqTestData) mov ecx,[edx+4] mov edx,65 call System.Linq.Enumerable.Contains[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) ret ; Total bytes of code 14 ``` ```assembly ; System.Linq.Enumerable.Contains[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) push ebp mov ebp,esp push edi push esi mov esi,ecx mov edi,edx mov edx,esi mov ecx,offset MT_System.Collections.Generic.ICollection`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax jne short M01_L00 push 0 mov ecx,esi mov edx,edi call System.Linq.Enumerable.Contains[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32, System.Collections.Generic.IEqualityComparer`1) pop esi pop edi pop ebp ret M01_L00: mov ecx,eax mov edx,edi call dword ptr ds:[2B8] pop esi pop edi pop ebp ret ; Total bytes of code 54 ``` #### System.Linq.Tests.Perf_Enumerable.Except(input: IEnumerable) ```log [3582.134 ; 3664.405) | @@@@@@ [3664.405 ; 3759.063) | [3759.063 ; 3853.721) | [3853.721 ; 3948.378) | [3948.378 ; 4060.049) | [4060.049 ; 4171.441) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Except(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,ecx mov edx,[edx+4] mov ecx,edx call System.Linq.Enumerable.Except[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop ebp ret ; Total bytes of code 29 ``` ```assembly ; System.Linq.Enumerable.Except[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp test ecx,ecx je short M01_L00 test edx,edx je short M01_L01 push 0 call System.Linq.Enumerable.ExceptIterator[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEqualityComparer`1) pop ebp ret M01_L00: mov ecx,4 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L01: mov ecx,0E call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 42 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[284] mov [ebp+0FFE4],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[288] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[28C] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[288] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[290] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[290] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 105 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Except(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,ecx mov edx,[edx+4] mov ecx,edx call System.Linq.Enumerable.Except[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop ebp ret ; Total bytes of code 29 ``` ```assembly ; System.Linq.Enumerable.Except[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp test ecx,ecx je short M01_L00 test edx,edx je short M01_L01 push 0 call System.Linq.Enumerable.ExceptIterator[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEqualityComparer`1) pop ebp ret M01_L00: mov ecx,4 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L01: mov ecx,0E call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 42 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[278] mov ecx,eax mov [ebp+0FFE4],ecx call dword ptr ds:[27C] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[280] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[27C] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[284] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[284] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 104 ``` #### System.Linq.Tests.Perf_Enumerable.Prepend(input: IEnumerable) ```log [3014.003 ; 3106.571) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [3106.571 ; 3230.698) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [3230.698 ; 3313.074) | @@@@@@@@@@@@@@@@@@@@@@@@ [3313.074 ; 3418.575) | @@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Prepend(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push edi push esi push ebx sub esp,18 xor eax,eax mov [ebp+0FFE0],eax mov [ebp+0FFE4],eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov esi,ecx mov edi,edx mov ecx,0A626EA0 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov ebx,ds:[1EA8] mov ecx,[edi+4] call dword ptr ds:[284] mov [ebp+0FFDC],eax mov ecx,[ebp+0FFDC] call dword ptr ds:[288] test eax,eax je short M00_L01 M00_L00: mov ecx,[ebp+0FFDC] call dword ptr ds:[28C] mov edx,eax mov ecx,ebx call System.Linq.Enumerable.Prepend[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) mov ebx,eax mov ecx,[ebp+0FFDC] call dword ptr ds:[288] test eax,eax jne short M00_L00 M00_L01: mov ecx,[ebp+0FFDC] call dword ptr ds:[290] jmp short M00_L03 cmp dword ptr [ebp+0FFDC],0 je short M00_L02 mov ecx,[ebp+0FFDC] call dword ptr ds:[290] M00_L02: pop eax jmp eax M00_L03: mov edx,[esi+4] mov ecx,ebx call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) lea esp,[ebp+0FFF4] pop ebx pop esi pop edi pop ebp ret ; Total bytes of code 153 ``` ```assembly ; System.Linq.Enumerable.Prepend[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je short M01_L01 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+AppendPrependIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax jne short M01_L00 mov ecx,offset MT_System.Linq.Enumerable+AppendPrepend1Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI mov [ebx+18],edi mov byte ptr [ebx+1C],0 mov eax,ebx pop ebx pop esi pop edi pop ebp ret M01_L00: mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+30] call dword ptr [eax+8] pop ebx pop esi pop edi pop ebp ret M01_L01: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 100 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[298] mov [ebp+0FFE4],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[29C] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[2A0] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[29C] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[2A4] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[2A4] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 105 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Prepend(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push edi push esi push ebx sub esp,18 xor eax,eax mov [ebp+0FFE0],eax mov [ebp+0FFE4],eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov esi,ecx mov edi,edx mov ecx,9BC6E90 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov ebx,ds:[1EB0] mov ecx,[edi+4] call dword ptr ds:[278] mov edi,eax mov [ebp+0FFDC],edi mov ecx,edi call dword ptr ds:[27C] test eax,eax je short M00_L01 M00_L00: mov ecx,edi call dword ptr ds:[280] mov edx,eax mov ecx,ebx call System.Linq.Enumerable.Prepend[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) mov ebx,eax mov ecx,edi call dword ptr ds:[27C] test eax,eax jne short M00_L00 M00_L01: mov ecx,edi call dword ptr ds:[284] jmp short M00_L03 cmp dword ptr [ebp+0FFDC],0 je short M00_L02 mov ecx,[ebp+0FFDC] call dword ptr ds:[284] M00_L02: pop eax jmp eax M00_L03: mov edx,[esi+4] mov ecx,ebx call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) lea esp,[ebp+0FFF4] pop ebx pop esi pop edi pop ebp ret ; Total bytes of code 151 ``` ```assembly ; System.Linq.Enumerable.Prepend[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je short M01_L01 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+AppendPrependIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax jne short M01_L00 mov ecx,offset MT_System.Linq.Enumerable+AppendPrepend1Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI mov [ebx+18],edi mov byte ptr [ebx+1C],0 mov eax,ebx pop ebx pop esi pop edi pop ebp ret M01_L00: mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+30] call dword ptr [eax+8] pop ebx pop esi pop edi pop ebp ret M01_L01: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 100 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[28C] mov ecx,eax mov [ebp+0FFE4],ecx call dword ptr ds:[290] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[294] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[290] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[298] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[298] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 104 ``` #### System.Linq.Tests.Perf_Enumerable.Aggregate(input: IEnumerable) ```log [ -29.470 ; 29.470) | @@@@@@@@@@@ [ 29.470 ; 88.411) | [ 88.411 ; 147.351) | [ 147.351 ; 206.291) | [ 206.291 ; 265.232) | [ 265.232 ; 324.172) | [ 324.172 ; 383.113) | [ 383.113 ; 442.053) | [ 442.053 ; 500.993) | [ 500.993 ; 559.934) | [ 559.934 ; 601.994) | [ 601.994 ; 650.076) | @@@@@@@@@@@@ [ 650.076 ; 710.666) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [ 710.666 ; 769.606) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [ 769.606 ; 825.164) | @@@@@@@@@ [ 825.164 ; 884.104) | [ 884.104 ; 943.045) | [ 943.045 ; 1001.985) | [1001.985 ; 1060.926) | [1060.926 ; 1119.866) | [1119.866 ; 1178.806) | [1178.806 ; 1237.747) | [1237.747 ; 1296.687) | [1296.687 ; 1355.627) | [1355.627 ; 1414.568) | [1414.568 ; 1473.508) | [1473.508 ; 1516.225) | [1516.225 ; 1579.584) | @ [1579.584 ; 1638.525) | @@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Aggregate(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi sub esp,8 vzeroupper mov esi,[edx+4] mov edx,ds:[5554] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`3[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0ACA3418 lea edx,ds:[5554] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Aggregate[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`3) vxorps xmm0,xmm0,xmm0 vcvtsi2sd xmm0,xmm0,eax vmovsd qword ptr [ebp+0FFF4],xmm0 fld qword ptr [ebp+0FFF4] lea esp,[ebp+0FFFC] pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 106 ``` ```assembly ; System.Linq.Enumerable.Aggregate[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`3) push ebp mov ebp,esp push edi push esi sub esp,18 xor eax,eax mov [ebp+0FFEC],eax mov esi,edx test ecx,ecx je near ptr M01_L05 test esi,esi je near ptr M01_L06 call dword ptr ds:[284] mov [ebp+0FFE0],eax mov ecx,[ebp+0FFE0] call dword ptr ds:[288] test eax,eax je short M01_L00 mov ecx,[ebp+0FFE0] call dword ptr ds:[28C] mov edi,eax mov ecx,[ebp+0FFE0] call dword ptr ds:[290] test eax,eax je short M01_L02 jmp short M01_L01 M01_L00: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 M01_L01: mov ecx,[ebp+0FFE0] call dword ptr ds:[294] push eax mov edx,edi mov eax,esi mov ecx,[eax+4] call dword ptr [eax+0C] mov edi,eax mov ecx,[ebp+0FFE0] call dword ptr ds:[290] test eax,eax jne short M01_L01 M01_L02: mov ecx,[ebp+0FFE0] call dword ptr ds:[298] jmp short M01_L04 cmp dword ptr [ebp+0FFE0],0 je short M01_L03 mov ecx,[ebp+0FFE0] call dword ptr ds:[298] M01_L03: pop eax jmp eax M01_L04: mov eax,edi lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,5 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 180 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Aggregate(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi sub esp,8 vzeroupper mov esi,[edx+4] mov edx,ds:[555C] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`3[[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib],[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0AA23478 lea edx,ds:[555C] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Aggregate[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`3) vxorps xmm0,xmm0,xmm0 vcvtsi2sd xmm0,xmm0,eax vmovsd qword ptr [ebp+0FFF4],xmm0 fld qword ptr [ebp+0FFF4] lea esp,[ebp+0FFFC] pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 106 ``` ```assembly ; System.Linq.Enumerable.Aggregate[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`3) push ebp mov ebp,esp push edi push esi push ebx sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov esi,edx test ecx,ecx je near ptr M01_L05 test esi,esi je near ptr M01_L06 call dword ptr ds:[278] mov edi,eax mov [ebp+0FFDC],edi mov ecx,edi call dword ptr ds:[27C] test eax,eax je short M01_L00 mov ecx,edi call dword ptr ds:[280] mov ebx,eax mov ecx,edi call dword ptr ds:[284] test eax,eax je short M01_L02 jmp short M01_L01 M01_L00: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 M01_L01: mov ecx,edi call dword ptr ds:[288] push eax mov edx,ebx mov eax,esi mov ecx,[eax+4] call dword ptr [eax+0C] mov ebx,eax mov ecx,edi call dword ptr ds:[284] test eax,eax jne short M01_L01 M01_L02: mov ecx,edi call dword ptr ds:[28C] jmp short M01_L04 cmp dword ptr [ebp+0FFDC],0 je short M01_L03 mov ecx,[ebp+0FFDC] call dword ptr ds:[28C] M01_L03: pop eax jmp eax M01_L04: mov eax,ebx lea esp,[ebp+0FFF4] pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,5 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 178 ``` #### System.Linq.Tests.Perf_Enumerable.All_AllElementsMatch(input: IEnumerable) ```log [603.555 ; 627.912) | @@@@@@@@@@@@@@@@@@@@@ [627.912 ; 644.059) | [644.059 ; 668.076) | @@@@@@@@@@@@@@@@@@@@@@@@@@ [668.076 ; 691.565) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [691.565 ; 719.574) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [719.574 ; 743.063) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [743.063 ; 765.706) | @@@@ [765.706 ; 789.195) | @@@@@@@@@@@@@@@@@@@@@@@@ [789.195 ; 811.102) | @@@@@@@@ [811.102 ; 850.032) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.All_AllElementsMatch(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5524] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0B3F33A8 lea edx,ds:[5524] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.All[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 81 ``` ```assembly ; System.Linq.Enumerable.All[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push esi sub esp,1C xor eax,eax mov [ebp+0FFE0],eax mov [ebp+0FFF0],eax mov esi,edx test ecx,ecx je near ptr M01_L08 test esi,esi je near ptr M01_L09 call dword ptr ds:[284] mov [ebp+0FFE0],eax mov ecx,[ebp+0FFE0] call dword ptr ds:[288] test eax,eax je short M01_L02 M01_L00: mov ecx,[ebp+0FFE0] call dword ptr ds:[28C] mov edx,eax mov eax,esi mov ecx,[eax+4] call dword ptr [eax+0C] test eax,eax je short M01_L01 mov ecx,[ebp+0FFE0] call dword ptr ds:[288] test eax,eax jne short M01_L00 jmp short M01_L02 M01_L01: xor ecx,ecx mov [ebp+0FFE4],ecx mov dword ptr [ebp+0FFEC],0 mov dword ptr [ebp+0FFF0],0FC push offset M01_L03 jmp short M01_L04 M01_L02: mov ecx,[ebp+0FFE0] call dword ptr ds:[290] jmp short M01_L06 M01_L03: mov dword ptr [ebp+0FFF0],0 jmp short M01_L07 M01_L04: cmp dword ptr [ebp+0FFE0],0 je short M01_L05 mov ecx,[ebp+0FFE0] call dword ptr ds:[290] M01_L05: pop eax jmp eax M01_L06: mov eax,1 lea esp,[ebp+0FFFC] pop esi pop ebp ret M01_L07: mov eax,[ebp+0FFE4] lea esp,[ebp+0FFFC] pop esi pop ebp ret M01_L08: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L09: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 199 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.All_AllElementsMatch(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[552C] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0B1B3408 lea edx,ds:[552C] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.All[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 81 ``` ```assembly ; System.Linq.Enumerable.All[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi sub esp,1C xor eax,eax mov [ebp+0FFDC],eax mov [ebp+0FFEC],eax mov esi,edx test ecx,ecx je near ptr M01_L08 test esi,esi je near ptr M01_L09 call dword ptr ds:[278] mov edi,eax mov [ebp+0FFDC],edi mov ecx,edi call dword ptr ds:[27C] test eax,eax je short M01_L02 M01_L00: mov ecx,edi call dword ptr ds:[280] mov edx,eax mov eax,esi mov ecx,[eax+4] call dword ptr [eax+0C] test eax,eax je short M01_L01 mov ecx,edi call dword ptr ds:[27C] test eax,eax jne short M01_L00 jmp short M01_L02 M01_L01: xor ecx,ecx mov [ebp+0FFE0],ecx mov dword ptr [ebp+0FFE8],0 mov dword ptr [ebp+0FFEC],0FC push offset M01_L03 jmp short M01_L04 M01_L02: mov ecx,edi call dword ptr ds:[284] jmp short M01_L06 M01_L03: mov dword ptr [ebp+0FFEC],0 jmp short M01_L07 M01_L04: mov edi,[ebp+0FFDC] test edi,edi je short M01_L05 mov ecx,edi call dword ptr ds:[284] M01_L05: pop eax jmp eax M01_L06: mov eax,1 lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M01_L07: mov eax,[ebp+0FFE0] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M01_L08: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L09: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 200 ``` #### System.Linq.Tests.Perf_Enumerable.Take_All(input: IEnumerable) ```log [ 922.579 ; 954.038) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@ [ 954.038 ; 977.371) | @@@@@@@@@@@@@@@@@@@@@@@@ [ 977.371 ; 1002.590) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [1002.590 ; 1024.036) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [1024.036 ; 1060.624) | @@@@@@@@@@@@@@@@@@@@@@ [1060.624 ; 1104.562) | @@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Take_All(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,ecx mov ecx,[edx+4] test ecx,ecx je short M00_L00 mov edx,63 call System.Linq.Enumerable.TakeIterator[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop ebp ret M00_L00: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 47 ``` ```assembly ; System.Linq.Enumerable.TakeIterator[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx mov edx,esi mov ecx,offset MT_System.Linq.IPartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax jne short M01_L01 mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov ebx,eax test ebx,ebx jne short M01_L00 mov ecx,offset MT_System.Linq.Enumerable+EnumerablePartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI xor eax,eax mov [ebx+18],eax dec edi mov [ebx+1C],edi mov eax,ebx pop ebx pop esi pop edi pop ebp ret M01_L00: mov ecx,offset MT_System.Linq.Enumerable+ListPartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX xor eax,eax mov [esi+14],eax lea eax,[edi+0FFFF] mov [esi+18],eax mov eax,esi pop ebx pop esi pop edi pop ebp ret M01_L01: mov ecx,eax mov edx,edi call dword ptr ds:[2D4] pop ebx pop esi pop edi pop ebp ret ; Total bytes of code 149 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[288] mov [ebp+0FFE4],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[28C] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[290] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[28C] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[294] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[294] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 105 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Take_All(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,ecx mov ecx,[edx+4] test ecx,ecx je short M00_L00 mov edx,63 call System.Linq.Enumerable.TakeIterator[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop ebp ret M00_L00: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 47 ``` ```assembly ; System.Linq.Enumerable.TakeIterator[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Int32) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx mov edx,esi mov ecx,offset MT_System.Linq.IPartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE test eax,eax jne short M01_L01 mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov ebx,eax test ebx,ebx jne short M01_L00 mov ecx,offset MT_System.Linq.Enumerable+EnumerablePartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI xor eax,eax mov [ebx+18],eax dec edi mov [ebx+1C],edi mov eax,ebx pop ebx pop esi pop edi pop ebp ret M01_L00: mov ecx,offset MT_System.Linq.Enumerable+ListPartition`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX xor eax,eax mov [esi+14],eax lea eax,[edi+0FFFF] mov [esi+18],eax mov eax,esi pop ebx pop esi pop edi pop ebp ret M01_L01: mov ecx,eax mov edx,edi call dword ptr ds:[2C8] pop ebx pop esi pop edi pop ebp ret ; Total bytes of code 149 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[27C] mov ecx,eax mov [ebp+0FFE4],ecx call dword ptr ds:[280] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[284] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[280] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[288] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[288] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 104 ``` #### System.Linq.Tests.Perf_Enumerable.WhereFirst_LastElementMatches(input: IEnumerable) ```log [681.339 ; 696.184) | @@ [696.184 ; 713.756) | [713.756 ; 740.785) | @@@@@@@@@@@@@@@@ [740.785 ; 760.052) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [760.052 ; 776.582) | @@@@@@@@@@@@ [776.582 ; 807.183) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [807.183 ; 830.114) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [830.114 ; 860.151) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.WhereFirst_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[550C] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0B1B3378 lea edx,ds:[550C] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax call System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 88 ``` ```assembly ; System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L05 test edi,edi je near ptr M01_L06 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax je short M01_L00 mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+2C] call dword ptr [eax+8] jmp near ptr M01_L04 M01_L00: mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY mov ebx,eax test ebx,ebx je short M01_L02 cmp dword ptr [ebx+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+WhereArrayIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L01: mov ecx,0A8070C0 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1ED4] jmp short M01_L04 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L04: pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 268 ``` ```assembly ; System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp push eax lea edx,[ebp+0FFFC] call System.Linq.Enumerable.TryGetFirst[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Boolean ByRef) cmp byte ptr [ebp+0FFFC],0 je short M02_L00 mov esp,ebp pop ebp ret M02_L00: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 ; Total bytes of code 28 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.WhereFirst_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5514] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0B1D33C8 lea edx,ds:[5514] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax call System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 88 ``` ```assembly ; System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L05 test edi,edi je near ptr M01_L06 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax je short M01_L00 mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+2C] call dword ptr [eax+8] jmp near ptr M01_L04 M01_L00: mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY mov ebx,eax test ebx,ebx je short M01_L02 cmp dword ptr [ebx+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+WhereArrayIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L01: mov ecx,0A8270B0 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1EDC] jmp short M01_L04 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L04: pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 268 ``` ```assembly ; System.Linq.Enumerable.First[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp push eax lea edx,[ebp+0FFFC] call System.Linq.Enumerable.TryGetFirst[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, Boolean ByRef) cmp byte ptr [ebp+0FFFC],0 je short M02_L00 mov esp,ebp pop ebp ret M02_L00: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 ; Total bytes of code 28 ``` #### System.Linq.Tests.Perf_Enumerable.WhereSingleOrDefault_LastElementMatches(input: List) ```log [404.560 ; 418.734) | @ [418.734 ; 429.190) | [429.190 ; 443.364) | @@@@@@@@@@@@@ [443.364 ; 461.758) | @ [461.758 ; 475.931) | @@@@@@@@@@@@@@@@@@@@@ [475.931 ; 492.697) | @@@@@@@ [492.697 ; 506.870) | @@@@@@@@@@@@@@@@@@@ [506.870 ; 526.927) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [526.927 ; 542.995) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [542.995 ; 557.168) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [557.168 ; 575.045) | @@@@@@@@@@@@@@@@@@@@@@@@@@@ [575.045 ; 589.218) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [589.218 ; 611.183) | @@ [611.183 ; 625.357) | @@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.WhereSingleOrDefault_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[552C] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0ACF33B8 lea edx,ds:[552C] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax call System.Linq.Enumerable.SingleOrDefault[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 88 ``` ```assembly ; System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L05 test edi,edi je near ptr M01_L06 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax je short M01_L00 mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+2C] call dword ptr [eax+8] jmp near ptr M01_L04 M01_L00: mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY mov ebx,eax test ebx,ebx je short M01_L02 cmp dword ptr [ebx+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+WhereArrayIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L01: mov ecx,0A356EA0 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1ED0] jmp short M01_L04 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L04: pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 268 ``` ```assembly ; System.Linq.Enumerable.SingleOrDefault[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp push edi push esi sub esp,1C xor eax,eax mov [ebp+0FFDC],eax mov [ebp+0FFEC],eax mov esi,ecx test esi,esi je near ptr M02_L09 mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov edi,eax test edi,edi je short M02_L01 mov ecx,edi call dword ptr ds:[2C4] test eax,eax je short M02_L00 cmp eax,1 jne near ptr M02_L10 mov ecx,edi xor edx,edx call dword ptr ds:[2C8] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L00: xor eax,eax lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L01: mov ecx,esi call dword ptr ds:[2B0] mov [ebp+0FFDC],eax mov ecx,[ebp+0FFDC] call dword ptr ds:[2B4] test eax,eax jne short M02_L02 xor ecx,ecx mov [ebp+0FFE0],ecx mov dword ptr [ebp+0FFE8],0 mov dword ptr [ebp+0FFEC],0FC push offset M02_L04 jmp short M02_L06 M02_L02: mov ecx,[ebp+0FFDC] call dword ptr ds:[2B8] mov esi,eax mov ecx,[ebp+0FFDC] call dword ptr ds:[2BC] test eax,eax jne short M02_L03 mov [ebp+0FFE0],esi mov dword ptr [ebp+0FFE8],0 mov dword ptr [ebp+0FFEC],0FC push offset M02_L05 jmp short M02_L06 M02_L03: mov ecx,[ebp+0FFDC] call dword ptr ds:[2C0] jmp short M02_L10 M02_L04: mov dword ptr [ebp+0FFEC],0 jmp short M02_L08 M02_L05: mov dword ptr [ebp+0FFEC],0 jmp short M02_L08 M02_L06: cmp dword ptr [ebp+0FFDC],0 je short M02_L07 mov ecx,[ebp+0FFDC] call dword ptr ds:[2C0] M02_L07: pop eax jmp eax M02_L08: mov eax,[ebp+0FFE0] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L09: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M02_L10: call System.Linq.ThrowHelper.ThrowMoreThanOneElementException() int 3 ; Total bytes of code 263 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.WhereSingleOrDefault_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5534] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0A6C3418 lea edx,ds:[5534] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax call System.Linq.Enumerable.SingleOrDefault[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 88 ``` ```assembly ; System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L05 test edi,edi je near ptr M01_L06 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax je short M01_L00 mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+2C] call dword ptr [eax+8] jmp near ptr M01_L04 M01_L00: mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY mov ebx,eax test ebx,ebx je short M01_L02 cmp dword ptr [ebx+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+WhereArrayIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L01: mov ecx,9D26E90 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1ED8] jmp short M01_L04 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L04: pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 268 ``` ```assembly ; System.Linq.Enumerable.SingleOrDefault[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp push edi push esi sub esp,1C xor eax,eax mov [ebp+0FFDC],eax mov [ebp+0FFEC],eax mov esi,ecx test esi,esi je near ptr M02_L09 mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov edi,eax test edi,edi je short M02_L01 mov ecx,edi call dword ptr ds:[2B8] test eax,eax je short M02_L00 cmp eax,1 jne near ptr M02_L10 mov ecx,edi xor edx,edx call dword ptr ds:[2BC] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L00: xor eax,eax lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L01: mov ecx,esi call dword ptr ds:[2A4] mov ecx,eax mov [ebp+0FFDC],ecx call dword ptr ds:[2A8] test eax,eax jne short M02_L02 xor ecx,ecx mov [ebp+0FFE0],ecx mov dword ptr [ebp+0FFE8],0 mov dword ptr [ebp+0FFEC],0FC push offset M02_L04 jmp short M02_L06 M02_L02: mov ecx,[ebp+0FFDC] call dword ptr ds:[2AC] mov esi,eax mov ecx,[ebp+0FFDC] call dword ptr ds:[2B0] test eax,eax jne short M02_L03 mov [ebp+0FFE0],esi mov dword ptr [ebp+0FFE8],0 mov dword ptr [ebp+0FFEC],0FC push offset M02_L05 jmp short M02_L06 M02_L03: mov ecx,[ebp+0FFDC] call dword ptr ds:[2B4] jmp short M02_L10 M02_L04: mov dword ptr [ebp+0FFEC],0 jmp short M02_L08 M02_L05: mov dword ptr [ebp+0FFEC],0 jmp short M02_L08 M02_L06: mov ecx,[ebp+0FFDC] test ecx,ecx je short M02_L07 call dword ptr ds:[2B4] mov ecx,[ebp+0FFDC] M02_L07: pop eax jmp eax M02_L08: mov eax,[ebp+0FFE0] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L09: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M02_L10: call System.Linq.ThrowHelper.ThrowMoreThanOneElementException() int 3 ; Total bytes of code 263 ``` #### System.Linq.Tests.Perf_Enumerable.WhereSingle_LastElementMatches(input: IEnumerable) ```log [681.271 ; 699.904) | @@@@@@@@@@@@@@@@@@@@@@@@ [699.904 ; 718.027) | [718.027 ; 736.660) | @@@@@@@@@@@@@@@@@@@@@@@@@ [736.660 ; 761.286) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [761.286 ; 790.511) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [790.511 ; 824.853) | @@@@@@@@@ [824.853 ; 856.066) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [856.066 ; 881.180) | [881.180 ; 900.622) | @@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.WhereSingle_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5528] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0B3D33B0 lea edx,ds:[5528] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax call System.Linq.Enumerable.Single[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 88 ``` ```assembly ; System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L05 test edi,edi je near ptr M01_L06 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax je short M01_L00 mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+2C] call dword ptr [eax+8] jmp near ptr M01_L04 M01_L00: mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY mov ebx,eax test ebx,ebx je short M01_L02 cmp dword ptr [ebx+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+WhereArrayIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L01: mov ecx,0AA36EA0 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1ED4] jmp short M01_L04 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L04: pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 268 ``` ```assembly ; System.Linq.Enumerable.Single[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp push edi push esi sub esp,1C xor eax,eax mov [ebp+0FFDC],eax mov [ebp+0FFEC],eax mov esi,ecx test esi,esi je near ptr M02_L07 mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov edi,eax test edi,edi je short M02_L00 mov ecx,edi call dword ptr ds:[2DC] test eax,eax je near ptr M02_L08 cmp eax,1 jne near ptr M02_L09 mov ecx,edi xor edx,edx call dword ptr ds:[2E0] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L00: mov ecx,esi call dword ptr ds:[2C8] mov [ebp+0FFDC],eax mov ecx,[ebp+0FFDC] call dword ptr ds:[2CC] test eax,eax je short M02_L01 mov ecx,[ebp+0FFDC] call dword ptr ds:[2D0] mov esi,eax mov ecx,[ebp+0FFDC] call dword ptr ds:[2D4] test eax,eax jne short M02_L02 mov [ebp+0FFE0],esi mov dword ptr [ebp+0FFE8],0 mov dword ptr [ebp+0FFEC],0FC push offset M02_L03 jmp short M02_L04 M02_L01: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 M02_L02: mov ecx,[ebp+0FFDC] call dword ptr ds:[2D8] jmp short M02_L09 M02_L03: mov dword ptr [ebp+0FFEC],0 jmp short M02_L06 M02_L04: cmp dword ptr [ebp+0FFDC],0 je short M02_L05 mov ecx,[ebp+0FFDC] call dword ptr ds:[2D8] M02_L05: pop eax jmp eax M02_L06: mov eax,[ebp+0FFE0] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L07: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M02_L08: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 M02_L09: call System.Linq.ThrowHelper.ThrowMoreThanOneElementException() int 3 ; Total bytes of code 235 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.WhereSingle_LastElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5530] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0AE63410 lea edx,ds:[5530] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) mov ecx,eax call System.Linq.Enumerable.Single[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 88 ``` ```assembly ; System.Linq.Enumerable.Where[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push edi push esi push ebx mov esi,ecx mov edi,edx test esi,esi je near ptr M01_L05 test edi,edi je near ptr M01_L06 mov edx,esi mov ecx,offset MT_System.Linq.Enumerable+Iterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS test eax,eax je short M01_L00 mov ecx,eax mov edx,edi mov eax,[eax] mov eax,[eax+2C] call dword ptr [eax+8] jmp near ptr M01_L04 M01_L00: mov edx,esi mov ecx,offset MT_System.Int32[] call CORINFO_HELP_ISINSTANCEOFARRAY mov ebx,eax test ebx,ebx je short M01_L02 cmp dword ptr [ebx+4],0 je short M01_L01 mov ecx,offset MT_System.Linq.Enumerable+WhereArrayIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L01: mov ecx,0A4C6E90 mov edx,2 call CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS mov eax,ds:[1EDC] jmp short M01_L04 M01_L02: mov edx,esi mov ecx,offset MT_System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFCLASS mov ebx,eax test ebx,ebx je short M01_L03 mov ecx,offset MT_System.Linq.Enumerable+WhereListIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov esi,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [esi+4],eax lea edx,[esi+10] call CORINFO_HELP_ASSIGN_REF_EBX lea edx,[esi+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,esi jmp short M01_L04 M01_L03: mov ecx,offset MT_System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ebx,eax call CORINFO_HELP_GETCURRENTMANAGEDTHREADID mov [ebx+4],eax lea edx,[ebx+10] call CORINFO_HELP_ASSIGN_REF_ESI lea edx,[ebx+14] call CORINFO_HELP_ASSIGN_REF_EDI mov eax,ebx M01_L04: pop ebx pop esi pop edi pop ebp ret M01_L05: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L06: mov ecx,0C call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 268 ``` ```assembly ; System.Linq.Enumerable.Single[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp push edi push esi sub esp,1C xor eax,eax mov [ebp+0FFDC],eax mov [ebp+0FFEC],eax mov esi,ecx test esi,esi je near ptr M02_L07 mov edx,esi mov ecx,offset MT_System.Collections.Generic.IList`1[[System.Int32, System.Private.CoreLib]] call CORINFO_HELP_ISINSTANCEOFINTERFACE mov edi,eax test edi,edi je short M02_L00 mov ecx,edi call dword ptr ds:[2D0] test eax,eax je near ptr M02_L08 cmp eax,1 jne near ptr M02_L09 mov ecx,edi xor edx,edx call dword ptr ds:[2D4] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L00: mov ecx,esi call dword ptr ds:[2BC] mov ecx,eax mov [ebp+0FFDC],ecx call dword ptr ds:[2C0] test eax,eax je short M02_L01 mov ecx,[ebp+0FFDC] call dword ptr ds:[2C4] mov esi,eax mov ecx,[ebp+0FFDC] call dword ptr ds:[2C8] test eax,eax jne short M02_L02 mov [ebp+0FFE0],esi mov dword ptr [ebp+0FFE8],0 mov dword ptr [ebp+0FFEC],0FC push offset M02_L03 jmp short M02_L04 M02_L01: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 M02_L02: mov ecx,[ebp+0FFDC] call dword ptr ds:[2CC] jmp short M02_L09 M02_L03: mov dword ptr [ebp+0FFEC],0 jmp short M02_L06 M02_L04: mov ecx,[ebp+0FFDC] test ecx,ecx je short M02_L05 call dword ptr ds:[2CC] mov ecx,[ebp+0FFDC] M02_L05: pop eax jmp eax M02_L06: mov eax,[ebp+0FFE0] lea esp,[ebp+0FFF8] pop esi pop edi pop ebp ret M02_L07: mov ecx,10 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M02_L08: call System.Linq.ThrowHelper.ThrowNoElementsException() int 3 M02_L09: call System.Linq.ThrowHelper.ThrowMoreThanOneElementException() int 3 ; Total bytes of code 235 ``` #### System.Linq.Tests.Perf_Enumerable.LastWithPredicate_FirstElementMatches(input: IList) ```log [14.172 ; 14.751) | @@@@@@@@@@ [14.751 ; 15.293) | @@@@@@@@@@@@@@@ [15.293 ; 15.649) | @@@@@@@@@@@@@@@@@ [15.649 ; 16.091) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [16.091 ; 16.448) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [16.448 ; 16.831) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [16.831 ; 17.397) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [17.397 ; 18.100) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [18.100 ; 18.728) | [18.728 ; 19.355) | [19.355 ; 19.982) | [19.982 ; 20.610) | [20.610 ; 21.237) | [21.237 ; 21.962) | @@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.LastWithPredicate_FirstElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5518] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[54F8] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0B183390 lea edx,ds:[5518] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Last[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 81 ``` ```assembly ; System.Linq.Enumerable.Last[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push eax lea eax,[ebp+0FFFC] push eax call System.Linq.Enumerable.TryGetLast[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2, Boolean ByRef) cmp byte ptr [ebp+0FFFC],0 je short M01_L00 mov esp,ebp pop ebp ret M01_L00: call System.Linq.ThrowHelper.ThrowNoMatchException() int 3 ; Total bytes of code 29 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.LastWithPredicate_FirstElementMatches(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,[edx+4] mov edx,ds:[5520] test edx,edx jne short M00_L00 mov ecx,offset MT_System.Func`2[[System.Int32, System.Private.CoreLib],[System.Boolean, System.Private.CoreLib]] call CORINFO_HELP_NEWSFAST mov ecx,ds:[5500] test ecx,ecx je short M00_L01 lea edx,[eax+4] call CORINFO_HELP_ASSIGN_REF_ECX mov dword ptr [eax+0C],0A8733E0 lea edx,ds:[5520] call CORINFO_HELP_CHECKED_ASSIGN_REF_EAX mov edx,eax M00_L00: mov ecx,esi call System.Linq.Enumerable.Last[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) pop esi pop ebp ret M00_L01: call System.MulticastDelegate.ThrowNullThisInDelegateToInstance() int 3 ; Total bytes of code 81 ``` ```assembly ; System.Linq.Enumerable.Last[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2) push ebp mov ebp,esp push eax lea eax,[ebp+0FFFC] push eax call System.Linq.Enumerable.TryGetLast[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Func`2, Boolean ByRef) cmp byte ptr [ebp+0FFFC],0 je short M01_L00 mov esp,ebp pop ebp ret M01_L00: call System.Linq.ThrowHelper.ThrowNoMatchException() int 3 ; Total bytes of code 29 ``` #### System.Linq.Tests.Perf_Enumerable.Intersect(input: IEnumerable) ```log [4145.525 ; 4274.279) | @@@@@@ [4274.279 ; 4384.483) | [4384.483 ; 4494.687) | [4494.687 ; 4598.403) | [4598.403 ; 4729.771) | @@@@@@@@@@@@@@@@@ [4729.771 ; 4900.335) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ [4900.335 ; 5059.666) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@ [5059.666 ; 5218.085) | @ [5218.085 ; 5346.500) | @@@@ [5346.500 ; 5645.371) | @@@@@@@@@@ ``` ### Baseline Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Intersect(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,ecx mov edx,[edx+4] mov ecx,edx call System.Linq.Enumerable.Intersect[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop ebp ret ; Total bytes of code 29 ``` ```assembly ; System.Linq.Enumerable.Intersect[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp test ecx,ecx je short M01_L00 test edx,edx je short M01_L01 push 0 call System.Linq.Enumerable.IntersectIterator[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEqualityComparer`1) pop ebp ret M01_L00: mov ecx,4 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L01: mov ecx,0E call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 42 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[284] mov [ebp+0FFE4],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[288] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[28C] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[288] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[290] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[290] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 105 ``` ### Compare Jit Disasm ```assembly ; System.Linq.Tests.Perf_Enumerable.Intersect(System.Linq.Tests.LinqTestData) push ebp mov ebp,esp push esi mov esi,ecx mov edx,[edx+4] mov ecx,edx call System.Linq.Enumerable.Intersect[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1) mov ecx,eax mov edx,[esi+4] call BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) pop esi pop ebp ret ; Total bytes of code 29 ``` ```assembly ; System.Linq.Enumerable.Intersect[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1) push ebp mov ebp,esp test ecx,ecx je short M01_L00 test edx,edx je short M01_L01 push 0 call System.Linq.Enumerable.IntersectIterator[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEnumerable`1, System.Collections.Generic.IEqualityComparer`1) pop ebp ret M01_L00: mov ecx,4 call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 M01_L01: mov ecx,0E call System.Linq.ThrowHelper.ThrowArgumentNullException(System.Linq.ExceptionArgument) int 3 ; Total bytes of code 42 ``` ```assembly ; BenchmarkDotNet.Engines.ConsumerExtensions.Consume[[System.Int32, System.Private.CoreLib]](System.Collections.Generic.IEnumerable`1, BenchmarkDotNet.Engines.Consumer) push ebp mov ebp,esp push esi sub esp,18 xor eax,eax mov [ebp+0FFE8],eax mov [ebp+0FFEC],eax mov [ebp+0FFF0],eax mov [ebp+0FFF4],eax mov esi,edx call dword ptr ds:[278] mov ecx,eax mov [ebp+0FFE4],ecx call dword ptr ds:[27C] test eax,eax je short M02_L01 M02_L00: mov ecx,[ebp+0FFE4] call dword ptr ds:[280] mov [esi+24],eax mov ecx,[ebp+0FFE4] call dword ptr ds:[27C] test eax,eax jne short M02_L00 M02_L01: mov ecx,[ebp+0FFE4] call dword ptr ds:[284] jmp short M02_L03 cmp dword ptr [ebp+0FFE4],0 je short M02_L02 mov ecx,[ebp+0FFE4] call dword ptr ds:[284] M02_L02: pop eax jmp eax M02_L03: lea esp,[ebp+0FFFC] pop esi pop ebp ret ; Total bytes of code 104 ``` ### Docs [Profiling workflow for dotnet/runtime repository](https://github.com/dotnet/performance/blob/master/docs/profiling-workflow-dotnet-runtime.md) [Benchmarking workflow for dotnet/runtime repository](https://github.com/dotnet/performance/blob/master/docs/benchmarking-workflow-dotnet-runtime.md)