#include "windows.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
}
__int64 FiltTimeToQuardWord(PFILETIME pft) //将64两个DWORD值合到__int64量中的
{
__int64 t64 = 0;
t64 = pft -> dwHighDateTime;
t64 <<= 32;
t64 |= pft -> dwLowDateTime;
return t64;
}
FILETIME QuardWordToFileTime(__int64 t64)
{
FILETIME ftm;
ZeroMemory(&ftm, sizeof(ftm));
ftm.dwHighDateTime = (DWORD)(t64 >> 32);
ftm.dwLowDateTime = (DWORD)(t64 & 0xFFFFFFFF);
//不使用ftm.dwLowDataTime = (DWORD)(t64);
return ftm;
}
void Recalc()
{
FILETIME ftmAlogrithmTimeStart, ftmAlogrithmTimeEnd; //无意义
FILETIME ftmKernelTimeStart, ftmKernelTimeEnd;
FILETIME ftmUserTimeStart, ftmUserTimeEnd;
__int64 qwAlogrithmTime, qwKernelTime, qwUserTime;
//开始时间,进程正在执行期间,exittime时间无定义的可以传入开始时间的地址
//个人认为NULL可以的
GetThreadTimes(GetCurrentThread(), &ftmAlogrithmTimeStart, &ftmAlogrithmTimeStart, &ftmKernelTimeStart, &ftmUserTimeStart);
//code for alorithm, 执行某断代码的算法, 于此处
GetThreadTimes(GetCurrentThread(), &ftmAlogrithmTimeEnd, &ftmAlogrithmTimeStart, &ftmKernelTimeEnd, &ftmUserTimeEnd);
qwKernelTime = FiltTimeToQuardWord(&ftmKernelTimeEnd) - FiltTimeToQuardWord(&ftmKernelTimeStart);
qwUserTime = FiltTimeToQuardWord(&ftmUserTimeEnd) - FiltTimeToQuardWord(&ftmUserTimeStart);
qwAlogrithmTime = qwKernelTime + qwUserTime;
ftmAlogrithmTimeEnd = QuardWordToFileTime(qwAlogrithmTime);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
}
__int64 FiltTimeToQuardWord(PFILETIME pft) //将64两个DWORD值合到__int64量中的
{
__int64 t64 = 0;
t64 = pft -> dwHighDateTime;
t64 <<= 32;
t64 |= pft -> dwLowDateTime;
return t64;
}
FILETIME QuardWordToFileTime(__int64 t64)
{
FILETIME ftm;
ZeroMemory(&ftm, sizeof(ftm));
ftm.dwHighDateTime = (DWORD)(t64 >> 32);
ftm.dwLowDateTime = (DWORD)(t64 & 0xFFFFFFFF);
//不使用ftm.dwLowDataTime = (DWORD)(t64);
return ftm;
}
void Recalc()
{
FILETIME ftmAlogrithmTimeStart, ftmAlogrithmTimeEnd; //无意义
FILETIME ftmKernelTimeStart, ftmKernelTimeEnd;
FILETIME ftmUserTimeStart, ftmUserTimeEnd;
__int64 qwAlogrithmTime, qwKernelTime, qwUserTime;
//开始时间,进程正在执行期间,exittime时间无定义的可以传入开始时间的地址
//个人认为NULL可以的
GetThreadTimes(GetCurrentThread(), &ftmAlogrithmTimeStart, &ftmAlogrithmTimeStart, &ftmKernelTimeStart, &ftmUserTimeStart);
//code for alorithm, 执行某断代码的算法, 于此处
GetThreadTimes(GetCurrentThread(), &ftmAlogrithmTimeEnd, &ftmAlogrithmTimeStart, &ftmKernelTimeEnd, &ftmUserTimeEnd);
qwKernelTime = FiltTimeToQuardWord(&ftmKernelTimeEnd) - FiltTimeToQuardWord(&ftmKernelTimeStart);
qwUserTime = FiltTimeToQuardWord(&ftmUserTimeEnd) - FiltTimeToQuardWord(&ftmUserTimeStart);
qwAlogrithmTime = qwKernelTime + qwUserTime;
ftmAlogrithmTimeEnd = QuardWordToFileTime(qwAlogrithmTime);
}