If you've ever had questions about how expensive some 'day to day' ASP.NET operations are, here are the results of a test I threw together:
Details:
[1] - This was just a blank .txt file renamed to blank.aspx (to serve as a base-line for the ASP.NET pipeline).
[2] - Nothing more than a new WebForm.aspx created by adding a new webform to a VS.NET project.
[3] - The same as above, but with a single label added to the .aspx page, and the following code added to the Page_Load() Event:
this.Label1.Text = DateTime.Now.ToString()
+ " " + DateTime.Now.Millisecond.ToString();
[4] - A new webform added in VS.NET, augmented with a single DataGrid dropped onto the designer with the following code added to the Page_Load() Event:
ArrayList lotr = new ArrayList();
lotr.Add("smeagol");
lotr.Add("deagol");
lotr.Add("gandalf");
lotr.Add("bilbo");
lotr.Add("frodo");
lotr.Add("samwise");
this.DataGrid1.DataSource = lotr;
this.DataGrid1.DataBind();
lotr = null;
[5] - An 'empty' webform added in VS.NET and doomed for failure with the following code in the Page_Load() Event:
try
{
throw new NotImplementedException("irony");
}
catch
{
return;
}
[6] - You guessed it, WebForm from VS.NET with a DataGrid added in the designer and a SqlDataReader to populate it with the following code:
SqlConnection conn = new SqlConnection("Integrated Security=SSPI;etc.....;");
SqlCommand sproc = new SqlCommand("xsa_load_browsers",conn);
sproc.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlDataReader dr = sproc.ExecuteReader();
this.DataGrid1.DataSource = dr;
this.DataGrid1.DataBind();
conn.Close();
conn = null;
dr = null;
[7] - Just like [6], but the DataGrid is populated with a DataTable supplied by a DataAdapter as per the following code:
SqlConnection conn = new SqlConnection("Integrated Security=SSPI;etc.....;");
SqlCommand sproc = new SqlCommand("xsa_load_browsers",conn);
sproc.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(sproc);
DataTable bwsr = new DataTable();
da.Fill(bwsr);
this.DataGrid1.DataSource = bwsr;
this.DataGrid1.DataBind();
conn.Close();
conn = null;
bwsr = null;
Notes about the test:
1) The test was conducted on my laptop which is a Dell Inspiron 8200 with 1.8Ghz and 512MB RAM and 5400RPM Drive. All tests were taken in sequence and an IIS Reset was run between each test, and each page run once (to ensure that compilation time wasn't effecting testing) before each test.
2) Testing was done with Microsoft's Web Application Stress Tool. A 'template' was used for each test that consisted of 2 Threads (with 2 sockets each), simulating a total of 200 simulated users. Each test was run for 1 minute, so the requests/second listed above is the average request/second for the duration of each test.
3) The SQL Server being utilized was on my OWN box which does indeed impact performance. Other tests that I have conducted show that this number is actually very insignificant though (offloading persistence to another box generated about 8-12 additional page requests/second -- forcing my laptop to be both a SQL Server and WebServer is a bit of a perf hit, but so is forcing my laptop to connect to another machine repeatedly). The sproc used by both steps 6 & 7 was:
ALTER PROC [dbo].[xsa_load_browsers]
AS
SET NOCOUNT ON
SELECT
browserID,browserName
FROM
dbo.xsa_browsers
-- xsa_browsers is a view that abstracts
-- the table dbo.xsa_broswers_BSR
Don't hesitate to ask any questions, or provide feedback.