Created
August 28, 2024 05:32
-
-
Save akeit0/4fea895178459c1a8e30cda7324959c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| public class Test | |
| { | |
| struct Struct() | |
| { | |
| public int A = 0; | |
| } | |
| public int IncrementSlow() | |
| { | |
| var a = new Struct(); | |
| for (int i = 0; i < 100; i++) | |
| { | |
| a.A++; | |
| a.A++; | |
| } | |
| return a.A; | |
| } | |
| public int IncrementFast() | |
| { | |
| var a = new Struct(); | |
| for (int i = 0; i < 100; i++) | |
| { | |
| a= new Struct(){A = a.A + 1}; | |
| a= new Struct(){A = a.A + 1}; | |
| } | |
| return a.A; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Core CLR 8.0.724.31311 on x64 | |
| Test..ctor() | |
| L0000: ret | |
| Test.IncrementSlow() | |
| L0000: xor eax, eax | |
| L0002: xor ecx, ecx | |
| L0004: add eax, 2 | |
| L0007: inc ecx | |
| L0009: cmp ecx, 0x64 | |
| L000c: jl short L0004 | |
| L000e: ret | |
| Test.IncrementFast() | |
| L0000: xor eax, eax | |
| L0002: xor ecx, ecx | |
| L0004: inc eax | |
| L0006: inc eax | |
| L0008: inc ecx | |
| L000a: cmp ecx, 0x64 | |
| L000d: jl short L0004 | |
| L000f: ret | |
| Test+Struct..ctor() | |
| L0000: xor eax, eax | |
| L0002: mov [rcx], eax | |
| L0004: ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": 1, | |
| "target": "JIT ASM", | |
| "mode": "Release", | |
| "branch": "core-x64" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment