How can an attribute of the MethodImpl method (MethodImplOptions.NoInlining)] in C # affect performance when working with arrays?

How can the attribute of the method [MethodImpl(MethodImplOptions.NoInlining)] in C # affect performance when working with arrays?

I have a method that iterates over an int[][] array - jagged. With or without this attribute, measuring performance has the same effect.

Should the integration improve when working with gear arrays?

+4
source share
2 answers

Iterating a two-dimensional array will usually be expensive enough to hide the cost of one method call. And it makes it probable that the method does not become nested in any case, even without an attribute, just because there is too much machine code.

But look. Tools + Options, Debugging, General, untick "Disable JIT optimization when loading a module." Select the Release assembly. Set a breakpoint on the method call and run. When it breaks, right-click the source code and select "Go to disassembly". If you see a call instruction, it will not be inserted. You can see some kind of machine code before the call if the method takes arguments.

+4
source

Most likely, your method will not be indexed if you have an attribute or not - JIT has some limitations (not all methods can be built-in - i.e. those that have structure arguments) and some heuristics (most methods are not included - there are several heuristics based on the use of control flow, bytecode command count, etc.).

This is a useful summary of the rules: http://blogs.msdn.com/b/davidnotario/archive/2004/11/01/250398.aspx

+2
source

Source: https://habr.com/ru/post/1333733/


All Articles