I am curious if there is a build-in function in C++ for measuring the execution time?
I am using Windows at the moment. In Linux it’s pretty easy…
I am curious if there is a build-in function in C++ for measuring the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The best way on Windows, as far as I know, is to use
QueryPerformanceCounterandQueryPerformanceFrequency.QueryPerformanceCounter(LARGE_INTEGER*)places the performance counter’s value into the LARGE_INTEGER passed.QueryPerformanceFrequency(LARGE_INTEGER*)places the frequency the performance counter is incremented into the LARGE_INTEGER passed.You can then find the execution time by recording the counter as execution starts, and then recording the counter when execution finishes. Subtract the start from the end to get the counter’s change, then divide by the frequency to get the time in seconds.