Timing in an elegant way in c++
I am interested in timing the execution time of a free function or a member function (template or not). Call TheFunc the function in question, its call being TheFunc(/*parameters*/); or ReturnType ret = TheFunc(/*parameters*/); Of course I could wrap these function calls as follows : double duration = 0.0 ; std::clock_t start = std::clock(); TheFunc(/*parameters*/); duration = static_cast<double>(std::clock() - start) / static_cast<double>(CLOCKS_PER_SEC); or double duration = 0.0 ; std::clock_t start = std::clock(); ReturnType ret = TheFunc(/*parameters*/); duration = static_cast<double>(std: