Answer the question
In order to leave comments, you need to log in
Measuring the time of a section of code?
how to measure the execution time of a piece of code? Best in nanoseconds. I tried clock and GetTickCount, but they do not return the time, but the number of processor ticks. I found a chrono library, but there is no documentation in Russian .. Can anyone help with advice?
Answer the question
In order to leave comments, you need to log in
Labels or something correctly put and the language would not hurt to specify.
LARGE_INTEGER freq;
LARGE_INTEGER t1;
LARGE_INTEGER t2;
if(QueryPerformanceFrequency(&freq))
{
QueryPerformanceCounter(&t1);
..................................................
QueryPerformanceCounter(&t2);
double dt = t2.QuadPart - t1.QuadPart;
double elapsed_time = 1000 * dt / freq.QuadPart; //-- время в миллисекундах
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question