我需要一种简单的方法(如果可能的话,紧凑)在计算时间时执行一个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)
我知道秒表的方式......更紧凑吗?