C ++でいくつかのコードの実行時間を測定する最善の方法は何でしょうか。ストップウォッチ(.Net)同様のクラスが組み込まれていますか?私はVS2010でC ++を開発しています。どのように(もし)私は私のC + +プロジェクト内で.Netライブラリを使用できますか?前もって感謝します。
clock()
AFAIK C ++には、.NETのStopwatchのような標準クラスはありません。
http://cplus.about.com/od/howtodothingsi2/a/timing.htm is an example for a high resolution timer on the windows platform.
A platform independent implementation for such timers is: http://www.boost.org/libs/timer/doc/index.html
HTH
http://code.google.com/p/cpp-stopwatch 、それは普通のC ++であり、依存関係がなく、便利なVisual Studioソリューションが付属しています。ああ、私はそれを書きました。
QueryPerformanceCounterを使用すると、コードを「プロファイリング」するときに、より良いタイミングを得ることができます(完璧ではありませんが、初心者には十分なはずです)。
BOOL WINAPI QueryPerformanceCounter( __out LARGE_INTEGER *lpPerformanceCount );
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx.