I want to know the runtime of my function written in C ++ on Linux. I found a lot of posts about this. I tried all the methods mentioned in this Timer Methods link to calculate the time. The following are the results of my function:
time() : 0 seconds
clock() : 0.01 seconds
gettimeofday() : 0.002869 seconds
rdtsc() : 0.00262336 seconds
clock_gettime() : 0.00672151 seconds
chrono : 0.002841 seconds
Please help me which method is reliable in my testimony, since all the results differ in testimony. I read that your OS switches between different tasks, so the readings may not be very accurate. Is there a way that I can just calculate the time spent on my function. I heard about the use of the profiling tool, but have not yet found an example for any function. Please guide me.
source
share