How long will it take you to consider performance issues when writing asp.net applications? Unfortunately, most developers are very sorry about the performance problem. The planning and design of performance really needs to be put in front and center position. You need to think about your goals and make sure that you have good performance as your goal, and then you need to evaluate your procedures, the more you evaluate, the more opportunities you will have to improve performance.
In this article I will explain an important tool included in the Microsoft Visual Studio Enterprise Edition: Microsoft Application Center Test. Serious web developers should put this tool in their own toolkit.
Application Center Test
Before leaving Microsoft, I attended the asp.net of 12 cities. One of these covers performance issues and introduces Microsoft application Center Test to a number of developers. This tool always generates a lot of interesting information and I have a lot of questions about it.
You will find that Application Center test is part of Application Center (which can be found on the old MSDN CD or DVD) or is installed in Visual Studio. NET Enterprise version of the Visual studio. NET 2003\visual Studio. NET Enterprise features directory. When you first open application Center test, you can see a tree view of the tests, results, and users that are available for navigating. First, I want to show that it's easy to set up tests.
Using Application Center Test
First, build a simple Web application. For example, I'll use the page shown in Figure 1 (note that I used some tips for writing asp.net pages online, and you don't need to write a complete Page_Load event statement).
Sample Web Application
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data " %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace=" System.Configuration" %>
<script runat="server">
public void Page_Load() {
using(SqlConnection connection =
new SqlConnection(ConfigurationSettings.AppSettings["Northwind"]))
{
SqlCommand command = new SqlCommand("SELECT * FROM Products", connection);
connection.Open();
DataGrid1.DataSource = command.ExecuteReader();
DataGrid1.DataBind();
}
}
</script>
<form runat="server">
<asp:DataGrid id="DataGrid1" runat="server" />
</form>
The above code is not the recommended method for constructing an application, but it is simple enough that we can perform some basic tests on it. Opening this page in a Web browser returns a filled table of data that is displayed as an HTML table.
Now that you know this page works, copy the link to the Clipboard and you'll need to use it. The link to this example on my computer is http://localhost/blackbelt/outputcache/test.aspx.
Next, navigate to Application Center test, right-click "Tests (Test)" and select "New test". It opens the New Test Wizard Welcome page. Click "Next" to select the source code for the new test and select "Record New test." Click "Next" again to select the test type, prompted to select the scripting language (we do not modify the default), click "Next", there are the interface shown in Figure 1:
Figure 1: New Test Wizard
The "Record Test" makes application Center test easy to use. Clicking on "Start Record" opens a new browser instance. Do not enter a URL in the address bar (should be About:blank). Our operation is to select tools in this new browser instance | Internet selection, and browse the Connections property page. Then click on the "LAN Settings" button and you will see the interface shown in Figure 2:
Figure 2: Connection settings
You will find that proxy settings information is populated and is not the same as normal. This is because application Center test opens a new browser instance and instructs it to use a dedicated proxy server running Application Center Test. Any request through the browser will be captured by the application Center test agent.
To complete the test, close the browser dialog box and paste the link to the ASP.net page for the test into the address bar. Click on the "Go" button in the browser or press ENTER directly, the data table appears again. Next, close the browser and you may see information similar to Figure 3:
Figure 3: The captured request
The details section of the request in the above dialog box is now populated with requests captured by the application Center test agent. This is also the HTTP request sent by the browser. Now click "Stop Record" and click "Next". You'll get a hint that you need to enter a name for the test (I'm using "my Test"), and then you can click "Finish" to close the wizard.
Congratulations to you! You're a performance testing engineer now-it's easy, right?
You can also choose a number of other settings and configuration options. You can see these settings by right-clicking the "My Test" node in the "Tests" list and choosing properties. In these options you can simulate multiple browsers, multiple users, parameters for the "warm-up" time (no results are reported), and the duration of the test. You can study these settings later and read some articles that discuss test principles and test strategies. We don't spend too much time on details and run tests directly.