find c++ execution time -


I'm curious if there is a construct function in C ++ to measure execution time? I am using Windows at this time in linux very easy ...

best on Windows The way, as far as I know, is to use QueryPerformanceCounter and QueryPerformanceFrequency

QueryPerformanceCounter (LARGE_INTEGER *) LARGE_INTEGER passed in the value spots of the display counter.

QueryPerformanceFrequency (LARGE_INTEGER *) Places Frequency display counter is incremented in LARGE_INTEGER passed.

You can then achieve execution time by recording as execution time counter, the execution starts, and then the execution ends while counting the record. Decrease starting from the end, get the change of the counter, then get the time in seconds to split by frequency

  LARGE_INTEGER start, finish, freq. QueryPerformanceFrequency (& amp; freq); QueryPerformanceCounter (& amp; Beginning); // Combine some query (and end) presentation; Std :: cout & lt; & Lt; "Execution" & lt; & Lt; (QuadPart - start.QuadPart) / (double freq.QuadPart) & lt; & Lt; Std :: endl;  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -