LoginSignup
34
40

More than 5 years have passed since last update.

C++で処理時間を計測

Last updated at Posted at 2014-01-17

実装した処理のパフォーマンスチューニングをする際に時間計測は必須です。
毎回調べているので、書き留めておきます。

time_count.cpp
#include <iostream>
#include <atltime.h>

int test(void){
    CFileTime cTimeStart, cTimeEnd;
    CFileTimeSpan cTimeSpan;
    cTimeStart = CFileTime::GetCurrentTime();           // 現在時刻

    //TOOD:ここに計測したい処理を記述

    cTimeEnd = CFileTime::GetCurrentTime();           // 現在時刻
    cTimeSpan = cTimeEnd - cTimeStart;
    std::cout<< "処理時間:" << cTimeSpan.GetTimeSpan()/10000 << "[ms]" << std::endl;
}
34
40
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
40