As a Programmer, I used to do a lot of profiling of my source code to measure the memory , CPU time during run time . In General , the process is called Profiling and there are plenty of tools available Such as Valgrind.
But if you would like to do a function profiling , the below Class & Macros comes very handy.
https://github.com/karthagokul/C-Performance-Tips/blob/master/CustomProfiler/profiler.h
You can include the above header and add the macros in the function you would like to profile like below.
int profileFuntion() { PROFILE_FUNCTION; return 0; }