我正在嘗試比較GPU與CPU的性能。對(duì)于NVIDIA GPU,我一直在使用這些cudaEvent_t類型來(lái)獲得非常精確的時(shí)間。對(duì)于CPU,我一直在使用以下代碼:// Timersclock_t start, stop;float elapsedTime = 0;// Capture the start timestart = clock();// Do something here.......// Capture the stop timestop = clock();// Retrieve time elapsed in millisecondselapsedTime = (float)(stop - start) / (float)CLOCKS_PER_SEC * 1000.0f;顯然,這段代碼只有在您數(shù)秒的情況下才是好的。而且,結(jié)果有時(shí)出來(lái)很奇怪。有誰(shuí)知道在Linux中創(chuàng)建高分辨率計(jì)時(shí)器的某種方法?
添加回答
舉報(bào)
0/150
提交
取消