Santanu Das
Santanu Das

Reputation: 1

Calculate execution time for multiple functions in C++

I have a function which in turn calls many functions. e.g.

void fun()
{
f1();
f2();
f3();
....
....
f50();
}

I want to calculate execution time of f1, f2....f50. Now if I calculate the time before and after execution of each function and then find the difference, I have to write it for all of these 50 functions which I want to avoid as it looks bad. Is there any simpler way to do this ?

Upvotes: 0

Views: 169

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409462

Use a wrapper function which gets the actual function to call as an argument, and have the timing code only in that wrapper function.

Upvotes: 1

Related Questions