2015-06-24 63 views
1

我通常在Linux中使用sysconfig(_SC_CLK_TCK)來獲取時鐘速率(總是返回100)。問題是我想用Atari Mint(TOS)使用dhrystone基準。我在名爲ARanyM的模擬器上安裝了atari mint。我在這裏也使用了sysconfig(_SC_CLK_TCK),但它返回類似於4294967295(這實際上是32位中的所有1值)如何設置仿真器的dhrystone基準時鐘頻率?

有沒有任何機構有任何建議?

回答

0

隨着Linux的使用:

#include <time.h> 

    double theseSecs = 0.0; 
    double startSecs = 0.0; 
    double secs; 
    double CPUsecs = 0.0; 
    double CPUutilisation = 0.0; 

    double answer = 0; 

    clock_t starts; 

    void start_CPU_time() 
    {  
     starts = clock();; 
     return; 
    } 

    void end_CPU_time() 
    { 
     CPUsecs = (double)(clock() - starts)/(double)CLOCKS_PER_SEC; 
     return; 
    }  



    struct timespec tp1; 
    void getSecs() 
    { 
    clock_gettime(CLOCK_REALTIME, &tp1); 
    theseSecs = tp1.tv_sec + tp1.tv_nsec/1e9;   
    return; 
    } 

    void start_time() 
    { 
     getSecs(); 
     startSecs = theseSecs; 
     return; 
    } 

    void end_time() 
    { 
     getSecs(); 
     secs = theseSecs - startSecs; 
     return; 
    }  

    void calculate() 
    { 
     int i, j; 
     for (i=1, i<1000001; i++) 
     { 
      for (i=j, j<1000001; j++) 
      { 
       answer = answer * (float)i/1000000.0; 
      } 
     } 
    } 

void main() 
{ 
    start_time(); 
    start_CPU_time(); 
    calculate(); 
    end_time(); 
    end_CPU_time(); 
    CPUutilisation = CPUsecs/secs/100.0; 
    printf"/n Answer %8.3f, Elapsed Time %7.4f, CPU Time %7.4f, 
      CPU Utilisation %8.4f/n, answer, secs, CPUsecs, CPUutilisation); 
} 
+0

感謝您的答覆,但只是要確定:)是,回答所需要的時鐘速率? 再次感謝您的幫助:) – nick

相關問題