Basically, I have a web application that uses asp.net mvc 4 framework. I use C# as my backend. At different times of the days, I noticed that the web application lags or is slow but I would like to figure out which times of day and some other information that would be useful in figuring out how to optimize the app. I want to be able to write an automated script that tests the web application at different times of the day and correlate it to the slowness of the application.
I'm pretty new to test automation, so I was wondering where could I start with scripting such things. In particular for asp.net web apps?
You can approach this from a few angles:
Log Stuff
Log page rendering times, database access times, and times of anything else that might cause slowness. Use a logging framework such as NLog that allows you to dial up and down the amount of detail you need in the log.
Get more detail while manually viewing
Integrate MiniProfiler in your website, and have it turn on when you log in.
Measure live performance of selected pages
The fast-start solution is to use one of the many external testing solutions out there. Google measure website performance free for a broad selection.
If you want to build this yourself, and especially if you want to test complex workflows, I have had great success with JMeter. JMeter is designed with the goal of stress testing a benchmarking, not live, environment. However, you could use it to periodically run tests against your production system as long as the tests do not place so much stress on the system so as to be the cause of the problem.
One advantage of using a hosted solution to measure page performance is that they can measure it from different parts of the world. In some cases, the network latency can be an important component of overall page performance.