开发者

Count SQLClient database queries from ASP.NET app

开发者 https://www.devze.com 2023-01-13 09:29 出处:网络
I need to do some performance testing for an ASP.NET MVC application and specifically want to measure how many database queries each HTTP request results in. The data access layer is using LINQ-to-SQL

I need to do some performance testing for an ASP.NET MVC application and specifically want to measure how many database queries each HTTP request results in. The data access layer is using LINQ-to-SQL.

I'd like to be able to automate the test开发者_如何学JAVAs so am looking for a good way to be able to do a before and after count of the number of SQL queries. The possibilities I can think of are:

  • A performance monitor counter for the ASP.NET process,
  • A system table in the MSSQL database that can be queried before and after each page request,
  • A property somewhere in the System.Data.SQLClient namespace that tracks the number of queries executed by the process.

Has anyone done this before and can perhaps point my down the right path?


The best approach I've been able to come up with so far is to use SQL Server Profiler to profile the db connections while the test app is running and get it to save the results to a database table (File->Properties->General). My test app can then query that table to see what and how many TSQL statements were executed.

0

精彩评论

暂无评论...
验证码 换一张
取 消