Strange behavior when profiling methods that uses EF

Code profiling for .NET Developers

Strange behavior when profiling methods that uses EF

Postby silviu » Fri Feb 01, 2013 12:59 pm


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?

Posts: 2
Joined: Fri Feb 01, 2013 12:37 pm

Postby Brian Donahue » Mon Feb 04, 2013 11:07 am


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).
Brian Donahue
Posts: 6590
Joined: Mon Aug 23, 2004 9:48 am

Postby silviu » Mon Feb 04, 2013 1:41 pm

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 <>, 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]
Posts: 2
Joined: Fri Feb 01, 2013 12:37 pm

Return to ANTS Performance Profiler Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests