我知道这个问题已经被问过几次了,但没有一个人真正帮助我,所以再问一次。
我正在使用 Windows XP 并运行 Visual Studio C++ 2008。
我正在查找的所有代码都使用 time.h 但我认为它可能在这里无法正常工作,因为结果让我感到怀疑。
这就是我想要的。
star time = get time some how (this is my question)
my code
end time = get time some how (this is my question)
time passed = start time - end time
这是我用来打印时间(以毫秒为单位)的方法。
void StartTimer( _int64 *pt1 )
{
QueryPerformanceCounter( (LARGE_INTEGER*)pt1 );
}
double StopTimer( _int64 t1 )
{
_int64 t2, ldFreq;
QueryPerformanceCounter( (LARGE_INTEGER*)&t2 );
QueryPerformanceFrequency( (LARGE_INTEGER*)&ldFreq );
return ((double)( t2 - t1 ) / (double)ldFreq) * 1000.0;
}
像这样使用它:
_int64 t1;
StartTimer( &t1 );
// do some stuff
printf( "Time = %.3f\n", StopTimer( t1 ));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)