473,796 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ 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(&t v1,&tz1);
double time_start1 = (double) tv1.tv_sec + (double)tv1.tv_ usec/
1000000.0;
//ALL ALGO PROCESSING HERE
gettimeofday(&t v2,&tz2);
double time_stop1 = (double) tv2.tv_sec + (double)tv2.tv_ usec/
1000000.0;
LOGGER.info("Ba ckgroundEstimat ionAlgoT 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(elapse d 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 8910
an********@gmai l.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(&t v1,&tz1);
double time_start1 = (double) tv1.tv_sec + (double)tv1.tv_ usec/
1000000.0;
//ALL ALGO PROCESSING HERE
gettimeofday(&t v2,&tz2);
double time_stop1 = (double) tv2.tv_sec + (double)tv2.tv_ usec/
1000000.0;
LOGGER.info("Ba ckgroundEstimat ionAlgoT 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(elapse d 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...@gmai l.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(&t v1,&tz1);
double time_start1 = (double) tv1.tv_sec + (double)tv1.tv_ usec/
1000000.0;
//ALL ALGO PROCESSING HERE
gettimeofday(&t v2,&tz2);
double time_stop1 = (double) tv2.tv_sec + (double)tv2.tv_ usec/
1000000.0;
LOGGER.info("Ba ckgroundEstimat ionAlgoT 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(elapse d 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 objektorientier ter Datenverarbeitu ng
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
2142
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 choices too risky for colleges ....?"), starting in about an hour. Bluntly, I think it's time to rally 'round the flag. http://chronicle.com/colloquylive/2003/08/opensource/chat.php Pass it on.
7
1696
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 IE6. Any suggestions? Here is an example page, js code below: http://www.aquariusyachting.co.uk/exterior.htm
8
3410
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 benchmark some function calls for Zope project and when I use t0=time.clock(); foo(); print time.clock()-t0 I get much smaller values than when I use time.clock() (most of them 0.0 but some 0.01) When I use time.time() I get values like...
6
3754
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 speed things up implementing some of the functions in C. So I need profiling. I first tried to use the default python profiler, but profiling my application multiplies the execution time by a factor between 10 and 100 ! So I decided to give a...
12
7410
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
1048
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 application
9
8302
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 following to try to determine which. import time # Determine if time.time is better than time.clock # The one with better resolution should be lower.
6
1908
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 very soon when running on the local machine ( measns where the web service is running). But it is taking lot of time when loaded on the remote machine. Can anybody please explain me how to solve this problem?
9
5538
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; $i < 10000000000000000000000000000000000000000; $i++)
0
10465
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10242
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7558
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6800
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5453
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.