LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-17-2008, 05:35 PM   #1
anto.anish
LQ Newbie
 
Registered: Oct 2008
Posts: 2

Rep: Reputation: 0
CPU time Vs WALL time, Sometimes Walltime lesser than Cputime ? Options


Hi users-

I have been using clock() for calculating CPU time and time() for
calculating Wall time. However, since time() does not provided milli/
microsecond accurancy, i started using gettimeofday() as below to
calculate walltime,


struct timeval tv1,tv2;
struct timezone tz1, tz2;
gettimeofday(&tv1,&tz1);
double time_start1 = (double) tv1.tv_sec + (double)tv1.tv_usec/
1000000.0;
//ALL ALGO PROCESSING HERE
gettimeofday(&tv2,&tz2);
double time_stop1 = (double) tv2.tv_sec + (double)tv2.tv_usec/
1000000.0;
LOGGER.info("BackgroundEstimationAlgoT Run WALL_TIME: %0.3f",(double)
(time_stop1 - time_start1));


Certain times, i have been noticing that WALLTIME calculated is lesser
than CPUTIME. I am not sure why ? Double checked the simple code,
nothing seems to be wrong in simple substraction. My understanding was
always WALLTIME(elapsed time) remains higher than CPUTIME(compute
time).


I run my application on head node of a Linux cluster comprising of 24 compute nodes, each with 8 processors.Any pointers as to why is this happening ?

Thanks
Anish

Last edited by anto.anish; 10-17-2008 at 05:38 PM.
 
Old 10-17-2008, 06:25 PM   #2
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
In a multiprocessor environment, CPU time can exceed wallclock time because you have multiple processors and if your process spends enough time running on more than one processor simultaneously, you'll have that effect.

After all, why else would you go multiprocessor, but to have more CPU cycles available per unit of wallclock time?
 
Old 10-17-2008, 06:33 PM   #3
anto.anish
LQ Newbie
 
Registered: Oct 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Hi Jim,

Yes, your expalanation best explains the difference. But, does this hold good if the application is just single threaded.

I was confused with the exactly opposite results - when i run the same application written in matlab(cputime always lesser than waltime) Vs same application written in c++(95% of runs generated cputime higher than walltime) from the same machine. Maybe, More processing cycles required to process the c++ code as compared to the matlab code.

Thanks
Anish

Last edited by anto.anish; 10-17-2008 at 07:01 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System time vs Hardware time and Daylight Savings Time Toadman Linux - General 6 03-17-2007 08:12 AM
diff. between elapsed time and cpu time madhugp Linux - General 1 01-15-2007 07:57 AM
The last wall has fallen for me, time to make it happen. Deviathan General 1 07-21-2006 01:26 PM
wall clock time of a running process ljmace1953 Linux - General 3 06-26-2006 01:14 PM


All times are GMT -5. The time now is 07:49 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration