我是C++的新手,我爲C++編寫了一個用於Linux的程序。我試圖將其轉換爲Windows。我的代碼是:C++代碼從Linux到Windows的轉換
struct Timer
{
struct tms t[2];
void STARTTIME (void)
{
times(t);
}
void STOPTIME(void)
{
times(t+1);
}
double USERTIME(void)
{
return ((double)((t+1)->tms_utime - t->tms_utime))/((double)sysconf(_SC_CLK_TCK));
}
};
對於tms_utime
我發現在Visual C++項QueryPerformanceCounter
,但我不能應用此。 對於sysconf(_SC_CLK_TCK)
我使用CLOCKS_PER_SEC
但我不知道這是多麼正確?什麼是Windows的等效代碼?
你看着Boost.Timer?擁有第三方庫來幫助跨平臺開發總是一個好主意。 – Ayjay
一個簡單的Windows/Linux定時器類[宋浩在這個zip](http://www.songho.ca/opengl/files/fbo.zip) – bobobobo