mercredi 29 avril 2015

timing a function call as if-statement condition in cpp

I have a function and sometimes it gets called as a condition in if-statements, and I am interested to time exactly these calls.

I wonder if there is any way to do something like this for timing it in cpp:

using watch = std::chrono::high_resolution_clock;
std::chrono::nanoseconds time(0);
if ( auto start = watch::now(); SOME_FUNCTION(); auto end = watch::now();)
{...}else{...}
time += (end - start);

Aucun commentaire:

Enregistrer un commentaire