I have a huge application that uses Entity Framework 4. It's WCF on the server (hosted inside Windows service) and WPF on the client.
Some of it's parts are slow, and I wonder if it's due to the fact that database access is slow.
I would like to continuously measure performance of that code, e.g. log every query's execution time (preferrably including EF's own stuff like materialization) somewhere to analyze later. How do I do that?
Tools like EFProf (because even if they can measure time it took db server to execute particular query, how do I run them for a week?) and Glimpse (it doesn't support Windows service and WPF) won't do in my case.
I considered making my own SqlConnection subclass, but my version only accepts EntityConnection in ObjectContext ctor, and EntityConnection is marked as sealed. And this option will only allow to measure raw sql queries execution time, not EF's code.
The only options I see now are: 1) to update to EF 6 and write SqlConnection subclass (this won't measure EF's own code) 2) update to later versions and use something like EF hooks library
And of course, it's not in a book (just looked at Mastering Enity Framework) - because most of us only need to work with a library, not know how quick it is (sarcasm).
There are all sorts of optimizations being made, both in the linq expression caching and what SQL server chooses to cache, the only way is to measure your performance speed and memory consumption
for your case, I think Microsoft has provided a simple way through "Measuring Entity Framework Performance using ETW"
Also, You can get some of this info through SQL profiler, it's just a lot more work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With