a question about clock() function

X

Xiaopeng Xiong

Hi all,

There are some programs using the clock() function to calculate the elapsed
time by:

//---------------example code----------------------

clock_t starttime=clock();

.......//statements here

clock_t endtime=clock();

double elapsedtime=(double)(endtime-starttime)/CLOCKS_PER_SEC;

//-------------------------------------------

The reference says "The clock function tells how much time the calling
process has used". However I am not sure the elapsedtime here means only the
CPU time or the whole execution time including I/O access. Any help is
appreciated.



Thanks.



Xiaopeng
 
J

Jerry Coffin

[email protected] says... said:
The reference says "The clock function tells how much time the calling
process has used". However I am not sure the elapsedtime here means only the
CPU time or the whole execution time including I/O access. Any help is
appreciated.

clock() is intended to measure only CPU time, but actually measures wall
time in enough implementations that it's difficult to know which you'll
get on a particular implementation without testing.
 
X

Xiaopeng Xiong

Does the "wall time" you mentioned mean the total time consumed by a
program? Thanks.
 
U

Unforgiven

Xiaopeng said:
Does the "wall time" you mentioned mean the total time consumed by a
program? Thanks.

"Wall time" usually refers to the amount of time elapsed on the clock that
hangs on your wall.
 
A

Alex Vinokur

Xiaopeng Xiong said:
Hi all,

There are some programs using the clock() function to calculate the elapsed
time by:

//---------------example code----------------------

clock_t starttime=clock();

......//statements here

clock_t endtime=clock();

double elapsedtime=(double)(endtime-starttime)/CLOCKS_PER_SEC;

//-------------------------------------------

The reference says "The clock function tells how much time the calling
process has used". However I am not sure the elapsedtime here means only the
CPU time or the whole execution time including I/O access. Any help is
appreciated.

Look at
http://groups.google.com/[email protected]


--
=====================================
Alex Vinokur
mailto:[email protected]
http://mathforum.org/library/view/10978.html
news://news.gmane.org/gmane.comp.lang.c++.perfometer
=====================================
 
X

Xiaopeng Xiong

Thanks all. One more question, there are lots of I/O operations in a
program,
does the clock() time capture the I/O time in it? If no, how to capture
that?


Thanks.

Xiaopeng
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top