#副標=ASP.NET效能調校研討系列
#大標=ASP.NET效能提示(Performance Tips) --(1)
===========<box>===================
Private void Page_Load(object sender, System.EventArgs e)
{
Response.Buffer=true;
for (int i=1; i<=1024; i++)
{
Response.Write("Processing Item."+i.ToString()+"
");
}
Response.End();
}
===============================================
==============<box>=================
Private void Page_Load(object sender, System.EventArgs e)
{
int[,] X=new int[100,100];
Trace.Write("Job Begins!");
for (int times=0; times<100; times++) //重覆執行100次以突顯速度差異
{
for (int i=0; i<100; i++)
{
for (int j=0; j<100; j++)
{
try
{
X[i,j]=j/(i % 3);
}
catch (DivideByZeroException ex)
//平均三次就會發生一次的除以零例外
{
X[i,j]=0;
}
}
}
}
Trace.Write("Job is Done!");
}
==================================
===================================
private void Page_Load(object sender, System.EventArgs e)
{
int[,] X=new int[100,100];
Trace.Write("Job Begins!");
for (int times=0; times<100; times++) //重覆執行100次以突顯速度差異
{
for (int i=0; i<100; i++)
{
for (int j=0; j<100; j++)
{
if (i % 3 != 0) //以邏輯判斷, 避免造成除以零的情形
{
X[i,j]=j/(i % 3);
}
else
{
X[i,j]=0;
}
}
}
}
Trace.Write("Job is Done!");
}
==========================================