gr_arm

Is it possible


Re: Visual C# Language Inline method in C# !!!

David Anton

No.




Re: Visual C# Language Inline method in C# !!!

Peter Ritchie

Not manually. The just-in-time compiler will inline methods whenever it can. Information on the criteria it uses to decide what can and won't be inlined can be seen here: http://blogs.msdn.com/ericgu/archive/2004/01/29/64717.aspx

You can only manually force a method not to inline with the MethodImplAttribute and MethodImplOptions.NoInlining.






Re: Visual C# Language Inline method in C# !!!

TheCPUWizard

Peter is quite correct.

One additional thing to point out, is that JIT inlining is disabled if a debugger is present. This is true regardless of the build configuration. If you are doing any timing tests, I strongly recommend not having Visual Studio or any other debugging capable program running on your machine at that time [some set the environment to indicate the presence of a debugger even it it is not attached].






Re: Visual C# Language Inline method in C# !!!

gr_arm

if I cut my method to set of 32 bytes methods , can I suppose that methodes will be online




Re: Visual C# Language Inline method in C# !!!

sirjis

Is your program running too slow If it is, then trying to force inlining will most likely not make any difference at all.

Methods are inlined automatically if it is obvious to the JIT compiler that they can easily and efficiently be inlined. Inlining is something .NET developers don't have to think about.





Re: Visual C# Language Inline method in C# !!!

Peter Ritchie

gr_arm wrote:
if I cut my method to set of 32 bytes methods , can I suppose that methodes will be online
That's just one of the criteria it uses; even if all of the criteria is met doesn't mean the method will be inlined.

Why do you care






Re: Visual C# Language Inline method in C# !!!

gr_arm

I try to make 100line method inline, that method is calling from 10 points.

How can I do that

I'm sure that inline method make my programm faster. am I right






Re: Visual C# Language Inline method in C# !!!

sirjis

gr_arm wrote:

I'm sure that inline method make my programm faster. am I right

No.

It probably won't make any noticeable difference whatsoever. It will definitely increase the size of the executable to have 10 copies of the code. The JIT would have to do extra work to inline it, too, which would slow that down every time the program is compiled (on the user's end), so inlining could be slower overall.

Bottom line is don't worry about inlining.

And I doubt that C++ would inline such a large method even if it did have the "inline" keyword.





Re: Visual C# Language Inline method in C# !!!

Peter Ritchie

gr_arm wrote:

I try to make 100line method inline, that method is calling from 10 points.

How can I do that

I'm sure that inline method make my programm faster. am I right

Without knowing how much faster it will be you're prematurely optimizing. Breaking up a single method into more than one simply to attempt to get an inlined method won't increase performance. Design your methods for how they should be used, not how they *might* be inlined.