Measure linq performance to sql and statistics

I have a web application that creates a DataContext at the beginning of a query and lets go to the end.

I would like to have convenient statistics for each page, for example
- the number of inserts and the time spent
- the number of deletions and the time spent
- the number of updates and the time spent
- the number of selected and spent time

I set it all up for insertions / updates / deletes by implementing the partial InsertXXX / UpdateXXX / DeleteXXX methods and tracking the number of samples and the time spent.

But how do I count SELECTs time

I'm not sure if there is a hook anywhere in Linq to SQL to insert some dimensions?

thanks

+3
source share
1 answer

To understand how long each of the running queries takes, you can run SQL Profiler in the database you are working with. You can use the Query Execution Plan to narrow down any results.

If you need to integrate this code more closely with your repository / data access code, you can use the stopwatch class to start executing your Linq-to-SQL methods.

http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx

0
source

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


All Articles