Last active
December 13, 2015 23:39
-
-
Save disktnk/4993393 to your computer and use it in GitHub Desktop.
C++ (windows) でのミリ秒計測ログ埋め込み→クラス化、スレッドアンセーフ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<windows.h> // and link to "winmm.lib" | |
// code | |
DWORD startTime, endTime; | |
startTime = timeGetTime(); | |
// ... | |
// elaplse target | |
// ... | |
endTime1 = timeGetTime(); | |
std::cout << "elaplse time is..." << endTime - startTime << std::endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "PerformanceLog.h" | |
#include <iostream> | |
namespace foo{ | |
PerformanceLog::PerformanceLog(std::string place) : place_(place) | |
{ | |
startTime_ = timeGetTime(); | |
} | |
PerformanceLog::~PerformanceLog(void) | |
{ | |
endTime_ = timeGetTime(); | |
std::cout << "[" << place_ << "]" << endTime_ - startTime_ << std::endl; | |
} | |
} // end of namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <windows.h> | |
namespace foo { | |
class PerformanceLog | |
{ | |
public: | |
PerformanceLog(std::string place); | |
~PerformanceLog(void); | |
private: | |
DWORD startTime_; | |
DWORD endTime_; | |
std::string place_; | |
}; | |
} // end of namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment