-
Notifications
You must be signed in to change notification settings - Fork 38
/
CalcCostTime.cpp
52 lines (40 loc) · 1 KB
/
CalcCostTime.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "CalcCostTime.h"
void CCostTime::Start()
{
::QueryPerformanceCounter(&time_start_);
}
void CCostTime::End()
{
::QueryPerformanceCounter(&time_end_);
}
double CCostTime::CostTime()
{
double dqFreq; //¼ÆʱÆ÷ƵÂÊ
LARGE_INTEGER f;
::QueryPerformanceFrequency(&f);
dqFreq=(double)f.QuadPart;
double dCostTime = (time_end_.QuadPart - time_start_.QuadPart) / dqFreq;
wchar_t buff[ 1024 ];
::swprintf_s(buff, L"%s : %0.10f s", cost_name_.c_str(), dCostTime);
debug_log(buff);
return dCostTime;
}
void CCostTime::debug_log( const std::wstring log_msg )
{
::OutputDebugString(log_msg.c_str());
HWND hSend = ::FindWindow(NULL, (LPCWSTR)&L"cswuyg_debug_Log_wnd");
COPYDATASTRUCT copydate;
copydate.cbData = (DWORD)(log_msg.length() + 1) * sizeof(TCHAR);
copydate.lpData = (PVOID)log_msg.c_str();
::SendMessage(hSend, WM_COPYDATA, 0, (LPARAM)©date);
}
CCostTime::CCostTime( const wchar_t* log_name )
: cost_name_(log_name)
{
Start();
}
CCostTime::~CCostTime()
{
End();
CostTime();
}