怎么知道,在C#中采用多少时间方法,例如,我有label1和方法
public int MakeSome(int a, int b)
{
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
// some operation
}
}
return returnIntValue;
}
Run Code Online (Sandbox Code Playgroud)
知道,如何知道MakeSome方法需要多少毫秒,并在label1中写入值.谢谢
CMS*_*CMS 14
你可以使用这个Stopwatch类:
Stopwatch st = new Stopwatch();
st.Start();
// call MakeSome method...
st.Stop();
Run Code Online (Sandbox Code Playgroud)
然后你可以检查st.ElapsedMilliseconds财产.
Eri*_*ert 11
使用System.Diagnostics命名空间中的Stopwatch类.
| 归档时间: |
|
| 查看次数: |
5485 次 |
| 最近记录: |