-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add AggressiveInlining to Double.CompareTo() and Single.CompareTo() #56501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -188,12 +188,17 @@ public int CompareTo(object? value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new ArgumentException(SR.Arg_MustBeDouble); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public int CompareTo(double value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (m_value < value) return -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (m_value > value) return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (m_value == value) return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return CompareToWithAtLeastOneNaN(value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private int CompareToWithAtLeastOneNaN(double value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Method | Toolchain | Mean | Ratio | Code Size |
|---|---|---|---|---|
| IsSorted | main\corerun.exe | 1,921,366.71 ns | 1.00 | 155 B |
| IsSorted | pr1\corerun.exe | 739,726.37 ns | 0.39 | 97 B |
| IsSorted | pr2\corerun.exe | 970,601.44 ns | 0.50 | 117 B |
| CopyAndSort | main\corerun.exe | 11,761,377.29 ns | 1.00 | 1,060 B |
| CopyAndSort | pr1\corerun.exe | 11,810,071.67 ns | 1.00 | 1,060 B |
| CopyAndSort | pr2\corerun.exe | 11,837,290.42 ns | 1.01 | 1,060 B |
| Search | main\corerun.exe | 58.53 ns | 1.00 | 207 B |
| Search | pr1\corerun.exe | 35.51 ns | 0.61 | 207 B |
| Search | pr2\corerun.exe | 38.65 ns | 0.66 | 207 B |
| CompareSequence | main\corerun.exe | 1,829,633.22 ns | 1.00 | 330 B |
| CompareSequence | pr1\corerun.exe | 1,452,953.83 ns | 0.79 | 306 B |
| CompareSequence | pr2\corerun.exe | 1,523,349.48 ns | 0.83 | 316 B |
I asked whether it would make sense to split it. I'm fine with the answer being "no" 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I have reverted the commit that split the inlining, so we're back to just regular aggressive inlined
Uh oh!
There was an error while loading. Please reload this page.