Does readonly make your code faster? #103
Replies: 6 comments 9 replies
-
|
When I tell folks to mark their fields |
Beta Was this translation helpful? Give feedback.
-
|
It looks like the assembly code in this post is from a Debug build, can you verify? |
Beta Was this translation helpful? Give feedback.
-
|
I wonder if (PGO){https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-8/#tiering-and-dynamic-pgo} would optimize Hey if anyone is looking for a place to make an open source contribution to .Net, taking advantage of |
Beta Was this translation helpful? Give feedback.
-
I believe PGO already does this. In Stephen Toubs excellent article on Performance Improvements in .NET 8, he mentions that:
|
Beta Was this translation helpful? Give feedback.
-
But a readonly instance field will still have different values across different instances, which means the JITter isn't any closer to optimize a method using that field than a non-readonly field. |
Beta Was this translation helpful? Give feedback.
-
|
Does |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Does readonly make your code faster?
In this blog post we will discover whether or not the readonly modifier can make your code faster. So without further ado let's get started.
https://steven-giesel.com/blogPost/50b84029-4f1e-4e6d-8fd1-0311b0605562
Beta Was this translation helpful? Give feedback.
All reactions