Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - The issue about clock() function???: (2 Items)
   
The issue about clock() function???  
Hi, guys

I used the clock() to measure the time of my function would take. The time_used was about 1s, but the actual wallclock 
time is about 20s in the real world. Is there some issue about clock function or a wrong CLOCKS_PER_SEC defined in <time
.h>?

My code is as follows:

    start_time = clock();
          DoSomething();
     stop_time = clock();

    float time_used = 0.0f;
    time_used = (float)((float)(stop_time - start_time)/(float)CLOCKS_PER_SEC);

BR
Jerry
RE: The issue about clock() function???  
Read clock() documentation, clock() measure actual CPU time and NOT human time.

-----Message d'origine-----
De : Jerry Van [mailto:community-noreply@qnx.com] 
Envoyé : 12 janvier 2011 21:14
À : general-community
Objet : The issue about clock() function???

Hi, guys

I used the clock() to measure the time of my function would take. The time_used was about 1s, but the actual wallclock 
time is about 20s in the real world. Is there some issue about clock function or a wrong CLOCKS_PER_SEC defined in <time
.h>?

My code is as follows:

    start_time = clock();
          DoSomething();
     stop_time = clock();

    float time_used = 0.0f;
    time_used = (float)((float)(stop_time - start_time)/(float)CLOCKS_PER_SEC);

BR
Jerry



_______________________________________________

General
http://community.qnx.com/sf/go/post82069