相关疑难解决方法(0)

如何轻松计时一块C#代码?

我需要一种简单的方法(如果可能的话,紧凑)在计算时间时执行一个C#块.与此C++代码类似的东西:

elapsed = time_call([&] 
   {
      for_each (a.begin(), a.end(), [&](int n) {
         results1.push_back(make_tuple(n, fibonacci(n)));
      });
   });   
Run Code Online (Sandbox Code Playgroud)

其中time_call是:

// Calls the provided work function and returns the number of milliseconds 
// that it takes to call that function.
template <class Function>
__int64 time_call(Function&& f)
{
   __int64 begin = GetTickCount();
   f();
   return GetTickCount() - begin;
}
Run Code Online (Sandbox Code Playgroud)

我知道秒表的方式......更紧凑吗?

c# c++

9
推荐指数
2
解决办法
2355
查看次数

标签 统计

c# ×1

c++ ×1