Visual C ++ Stopwatch

I wonder how best to measure the runtime of some C ++ code. Is there a class built into the Stopwatch (.Net)? I am developing C ++ on VS2010. How (if) can I use .Net libraries inside my C ++ project? Thanks in advance.

+5
source share
3 answers

AFAIK C ++ does not have a standard class such as a stopwatch in .NET.

http://cplus.about.com/od/howtodothingsi2/a/timing.htm is an example of a high-resolution timer on the Windows platform.

Regardless of the platform for such timers: http://www.boost.org/libs/timer/doc/index.html

NTN

+3
source
+2

You can use QueryPerformanceCounter to get the best time to “profile” some code (it is not perfect, but should be enough to run you).

BOOL WINAPI QueryPerformanceCounter( __out  LARGE_INTEGER *lpPerformanceCount );

http://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx .

+1
source

All Articles