Strange behavior when profiling methods that uses EF

Hi,

I have the following EF query:

DbContext.Priorities.OrderBy(x => x.Value).ToList()

Where Priorities maps over a table with only 4 records.

When I profile with ANTS Performance Profiler 7.4 says that it takes about 3 seconds, most of the time is spent in 46013 hidden methods without source. The corresponding SQL query takes just a few ms.
I'm profiling an ASP.NET web application (IIS) using Line-level and method-level timings method.

The same method but without the profiler started takes less than 200 ms.


Do you have any clue why the profiler is slowing that particular EF call?

Regards
Silviu

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hello,

    If the methods involved are really small, you may want to try disabling overhead correction in ANTS Performance Profiler settings. Unfortunately, with tight code loops, overhead correction can sometimes distort the times, and this is especially true for recursive code loops.

    I'm also not certain if the comparison is valid because I don't know what you used to come up with the 200ms figure - if you are using a different profiler, you'll want to use like-for-like settings (CPU time, source code/no source code, etc).
  • I disabled overhead correction but that didn't help.

    The 200 ms I measured using DateTime.Now before and after that method call.

    I send an email to Red Gate Support <[email protected]>, subject "RE: Your Red Gate Forum Topic: F0069192", with a screen-shot in ANTS Performance Profiler showing the problem I'm facing.

    GetPriorityList() method call takes 2,636 ms (Wall-clock time with Children), inside that node we have JIT overhead with 2,339 ms, inside which we have other JIT overhead with 0,001 ms and Profiler overhead with 0,001 ms.

    It seems that it's from JIT overhead, but when I'm running without ANTS profiler started there is no overhead.[/img]
Sign In or Register to comment.