相关疑难解决方法(0)

如何测量函数运行的时间?

我想看一个函数运行多长时间.所以我在表单上添加了一个计时器对象,我出来了这段代码:

private int counter = 0;

// Inside button click I have:
timer = new Timer();
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
Result result = new Result();
result = new GeneticAlgorithms().TabuSearch(parametersTabu, functia);
timer.Stop();
Run Code Online (Sandbox Code Playgroud)

和:

private void timer_Tick(object sender, EventArgs e)
{
    counter++;
    btnTabuSearch.Text = counter.ToString();
}
Run Code Online (Sandbox Code Playgroud)

但这并不算什么.为什么?

.net c# performance timer stopwatch

39
推荐指数
8
解决办法
4万
查看次数

标签 统计

.net ×1

c# ×1

performance ×1

stopwatch ×1

timer ×1