PostSharp does not affect speed

I came across incredibly good behavior with PostSharp. To evaluate the speed, I wrote a small program that will perform one function a certain number of times, and if PostSharp is turned on, it will generate and delete several hundred lines, only in memory (unfixed composition, so they are not automatic, interned). The cycle is executed in non-trivial (several milliseconds) time.

Now I can’t measure the difference over several million circulations, and the crazy launch of ~ 40 billion iterations made a difference of only a few nanoseconds against the non-PostSharp version making the same number of calls. This is impossible for me. There should be something wrong with my test. I had code verified by my colleagues, so I'm sure the code does what I intend.

So, is there something wrong with using string generation (what is the expected use in the intended applications) as a slow simulation for benchmarks?

Alternatively, did someone else perform (or know) PostSharp runtime performance analysis?

Thank.

+3
source share
3 answers

3 40 13 - , . - .

-, , - , , , ( ). , , .

+1

. PostSharp

​​ , , , : , , . PostSharp MSIL, JIT.

, , (1) PostSharp ( Reflector ) (2) . , , PostSharp ( , ).

-gael

+1

Can you modify your test so that the generated lines are used in the next iteration (line length written to the console) or something like that? Perhaps the compiler optimizes your program so that either the postsharp function is not executed at all, or it is called asynchronously, or executed on another processor, because there is no reason to synchronize with other iterations. If you bind it more tightly, it can cause the compiler to synchronize actions.

0
source

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


All Articles