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
Post a Comment