If you want to compare the performance of two processes, you can use this code to measure and print out the time takes by each process.
long startTime = DateTime.Now.Ticks;
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["con"]);
SqlCommand cmd = new SqlCommand("SELECT * FROM Contributions",con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
do
{
while(dr.Read())
{
SqlInt32 id = dr.GetSqlInt32(0);
SqlString name = dr.GetSqlString(1);
SqlMoney dueAmount = dr.GetSqlMoney(2);
SqlDateTime dueDate = dr.GetSqlDateTime(3);
Response.Write(id.ToString() + ": " + dueAmount.ToString() + ": " +
name.ToString() + ": " + ((DateTime)dueDate).ToString("d") + "<br>");
}
} while (dr.NextResult());
int y=0;
for(int x=0;x<=1000000000;x++)
{
y = y + 1;
}
long endTime = DateTime.Now.Ticks;
TimeSpan timeTaken = new TimeSpan(endTime - startTime);
Response.Write(timeTaken.ToString() + "<br>");
Comments