473,473 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CPU time Vs WALL time, Sometimes Walltime lesser than Cputime ?

Hi -

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 test my application on a Linux cluster with 24 compute nodes.
Any pointers as to why is this happening ?

Thanks
Anish
Oct 17 '08 #1
2 8884
an********@gmail.com wrote:
Hi -

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 test my application on a Linux cluster with 24 compute nodes.
Any pointers as to why is this happening ?
A few initial points...

Linux-specific questions belong to a Linux newsgroup.

'gettimeofday' is a non-standard function.

If your system has more than one logical CPU or your CPU is capable of
executing more than one instruction at a time, it is generally possible
to get more total CPU seconds than run-time, AIUI.

And the last one: what's your C++ language question?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 17 '08 #2
On Oct 17, 10:07*pm, anto.an...@gmail.com wrote:
Hi -

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).
You don't seem to be measuring CPU time at all here, so I'm not
sure what you're comparing. Clock() is supposed to return CPU
time, to the systems best approximation: it doesn't always, and
there will be some jitter, so it's quite possible for
differences of clock() to return a value larger than the
differences between to calls to time() (or gettimeofday()). The
differences shouldn't normally be very larger, however.
I test my application on a Linux cluster with 24 compute
nodes.
That could also affect things, if you were running multiple
threads. I would expect (but the standard doesn't say anything
about it) that clock() would be the sum of the times spent in
two threads.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 18 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Cameron Laird | last post by:
*The Chronicle of Higher Education*, which is more-or-less authoritative for US university administrations, is spon- soring a discussion on the place of open-source in universities ("... are such...
7
by: Nigel Molesworth | last post by:
I'm working on a site for a friend. I've found some image popup code that does what I want (borderless, close on exit) but for some reason I occasionally get the "popup blocked" information bar in...
8
by: peterbe | last post by:
What's the difference between time.clock() and time.time() (and please don't say clock() is the CPU clock and time() is the actual time because that doesn't help me at all :) I'm trying to...
6
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to...
12
by: aegis | last post by:
What is wall clock time? the standard doesn't define it but I see its use in past posts on clc. -- aegis
0
by: Fil | last post by:
This is a similar problem to what I am having. Where is the code though? Fil >-----Original Message----- >Hye friends, > I am Jigar Mehta from India. Currently I am developing an...
9
by: Ron Adam | last post by:
I'm having some cross platform issues with timing loops. It seems time.time is better for some computers/platforms and time.clock others, but it's not always clear which, so I came up with the...
6
by: Gouri.Mahajan7 | last post by:
Hello, When I press the button on the web page I am loading the user control on the web page. This user control is invoking some methods of the web service. The control on the web page is loaded...
9
by: Nichu | last post by:
Hello I set max_execution_time to 30 in php.ini file (i also checked in phpinfo). max_input_time is set to 45. But when I use in script something like that: while ( 1 == 1 ) or for ( $i=0;...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.