Hi,
I'm trying to find a decent way of measuring the running time of a
long-running program.
Say, the running time ranges from several seconds to more than a day.
The standard clock() function seems inadequate for this task.
(I read somewhere in this group that clock_t would likely overflow
after <1 hour).
Is there any better solution that can deal with this and be portable?
Thank you. 20 1944
On 25 Apr 2007 17:52:27 -0700, upperclass <th********@gmail.comwrote:
>Hi,
I'm trying to find a decent way of measuring the running time of a long-running program. Say, the running time ranges from several seconds to more than a day.
The standard clock() function seems inadequate for this task. (I read somewhere in this group that clock_t would likely overflow after <1 hour).
Is there any better solution that can deal with this and be portable? Thank you.
IIANM, difftime will portably give you the difference between two wall
clock times. See time.h. If you have posix (widely available) you can
a finer resolution than seconds.
Richard Harter wrote:
>
NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
Your clock is in serious error.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline.net
--
Posted via a free Usenet account from http://www.teranews.com
On Thu, 26 Apr 2007 00:25:27 -0400, CBFalconer <cb********@yahoo.com>
wrote:
>Richard Harter wrote:
>> NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
Your clock is in serious error.
Huh???
Richard Harter wrote:
On Thu, 26 Apr 2007 00:25:27 -0400, CBFalconer <cb********@yahoo.com>
wrote:
>>Richard Harter wrote:
>> NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
Your clock is in serious error.
Huh???
date
Thu Apr 26 18:58:54 NZST 2007
Your posting was dated 04/27/07 06:54
--
Ian Collins.
On Thu, 26 Apr 2007 19:01:11 +1200, Ian Collins <ia******@hotmail.com>
wrote:
>Richard Harter wrote:
>On Thu, 26 Apr 2007 00:25:27 -0400, CBFalconer <cb********@yahoo.com> wrote:
>>>Richard Harter wrote:
NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
Your clock is in serious error.
Huh??? date Thu Apr 26 18:58:54 NZST 2007
Your posting was dated 04/27/07 06:54
I am puzzled. The header info is:
Path:
border1.nntp.dca.giganews.com!nntp.giganews.com!lo cal01.nntp.dca.giganews.com!nntp.rapidnet.com!news .rapidnet.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
From: cr*@tiac.net (Richard Harter)
Newsgroups: comp.lang.c
Subject: Re: Measuring running time in a general + portable way
Date: Thu, 26 Apr 2007 13:22:00 GMT
Message-ID: <46****************@news.sbtc.net>
References: <11**********************@r30g2000prh.googlegroups .com>
X-Newsreader: Forte Free Agent 1.1/32.230
Lines: 21
NNTP-Posting-Host: 208.53.229.199
X-Trace:
sv3-rXZz57965mmdYAuUVuQRD17DWMURcFlXdXbDMUfMXl43d/T9ZXu6mX3LcF/m6gzUkMzDCQCu+XGcizQ!9GakYvoucalohljq5M2o1XqHkbjAC 2SCYvRKqvGjmKFnu/DwLjRCBkrPNmJTaIsnZs6DYQpsDns=
X-Complaints-To: ab***@rapidnet.com
X-DMCA-Complaints-To: ab***@rapidnet.com
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
X-Postfilter: 1.3.34
Xref: number1.nntp.dca.giganews.com comp.lang.c:743832
Where are you getting this 04/27/07 06:54 from?
Richard Harter said:
On Thu, 26 Apr 2007 19:01:11 +1200, Ian Collins <ia******@hotmail.com>
wrote:
>>Richard Harter wrote:
>>On Thu, 26 Apr 2007 00:25:27 -0400, CBFalconer <cb********@yahoo.comwrote:
Richard Harter wrote:
NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
Your clock is in serious error.
Huh??? date Thu Apr 26 18:58:54 NZST 2007
Your posting was dated 04/27/07 06:54
I am puzzled.
Why? Have you never seen people make mistakes before?
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
Richard Harter wrote:
On Thu, 26 Apr 2007 19:01:11 +1200, Ian Collins <ia******@hotmail.com>
wrote:
>>Richard Harter wrote:
>>>On Thu, 26 Apr 2007 00:25:27 -0400, CBFalconer <cb********@yahoo.com> wrote:
Richard Harter wrote:
NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
Your clock is in serious error.
Huh??? date Thu Apr 26 18:58:54 NZST 2007
Your posting was dated 04/27/07 06:54
I am puzzled. The header info is:
Path:
border1.nntp.dca.giganews.com!nntp.giganews.com!lo cal01.nntp.dca.giganews.com!nntp.rapidnet.com!news .rapidnet.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
From: cr*@tiac.net (Richard Harter)
Newsgroups: comp.lang.c
Subject: Re: Measuring running time in a general + portable way
Date: Thu, 26 Apr 2007 13:22:00 GMT
In my view of the header (and probably Chuck's), Date (as set by your
agent) was 04/27/07 06:54, which usually happens when the sender system
clock is wrong. The NNTP-Posting-Date is set by the server.
Only your postings appear to be in the future.
--
Ian Collins.
On Thu, 26 Apr 2007 20:29:03 +1200, Ian Collins <ia******@hotmail.com>
wrote:
>Richard Harter wrote:
>On Thu, 26 Apr 2007 19:01:11 +1200, Ian Collins <ia******@hotmail.com> wrote:
>>>Richard Harter wrote:
On Thu, 26 Apr 2007 00:25:27 -0400, CBFalconer <cb********@yahoo.com> wrote:
>Richard Harter wrote: > > > NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500 > >Your clock is in serious error.
Huh???
date Thu Apr 26 18:58:54 NZST 2007
Your posting was dated 04/27/07 06:54
I am puzzled. The header info is:
Path: border1.nntp.dca.giganews.com!nntp.giganews.com!l ocal01.nntp.dca.giganews.com!nntp.rapidnet.com!new s.rapidnet.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500 From: cr*@tiac.net (Richard Harter) Newsgroups: comp.lang.c Subject: Re: Measuring running time in a general + portable way Date: Thu, 26 Apr 2007 13:22:00 GMT
In my view of the header (and probably Chuck's), Date (as set by your agent) was 04/27/07 06:54, which usually happens when the sender system clock is wrong. The NNTP-Posting-Date is set by the server.
Only your postings appear to be in the future.
This is very weird. My clock has the correct time and date. Moreover
the times show up correctly when I download them.
On Thu, 26 Apr 2007 07:42:51 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>Richard Harter said:
>On Thu, 26 Apr 2007 19:01:11 +1200, Ian Collins <ia******@hotmail.com> wrote:
>>>Richard Harter wrote: On Thu, 26 Apr 2007 00:25:27 -0400, CBFalconer <cb********@yahoo.comwrote:
>Richard Harter wrote: > > NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500 > >Your clock is in serious error.
Huh???
date Thu Apr 26 18:58:54 NZST 2007
Your posting was dated 04/27/07 06:54
I am puzzled.
Why? Have you never seen people make mistakes before?
Ian says he's seeing my posting as coming in the future. Do you see
this also?
Richard Harter said:
Richard Heathfield wrote:
>>Richard Harter said:
>>Ian Collins wrote:
<snip>
>>>> Your posting was dated 04/27/07 06:54
I am puzzled.
Why? Have you never seen people make mistakes before?
Ian says he's seeing my posting as coming in the future. Do you see
this also?
No. In my view (er, literally!), he is mistaken.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
"Richard Harter" <cr*@tiac.netschrieb im Newsbeitrag
news:46****************@news.sbtc.net...
On Thu, 26 Apr 2007 07:42:51 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>>Richard Harter said:
>>On Thu, 26 Apr 2007 19:01:11 +1200, Ian Collins <ia******@hotmail.com> wrote:
Richard Harter wrote: On Thu, 26 Apr 2007 00:25:27 -0400, CBFalconer <cb********@yahoo.comwrote: > >>Richard Harter wrote: >> >> NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500 >> >>Your clock is in serious error. > Huh??? >
date Thu Apr 26 18:58:54 NZST 2007
Your posting was dated 04/27/07 06:54
I am puzzled.
Why? Have you never seen people make mistakes before?
Ian says he's seeing my posting as coming in the future. Do you see
this also?
Yes.
Confused am with pm? I see a 12 hours difference
Bye, Jojo
Richard Heathfield wrote:
Richard Harter said:
>>Richard Heathfield wrote:
>>>Richard Harter said:
Ian Collins wrote:
<snip>
>>>>>Your posting was dated 04/27/07 06:54
I am puzzled.
Why? Have you never seen people make mistakes before?
Ian says he's seeing my posting as coming in the future. Do you see this also?
No. In my view (er, literally!), he is mistaken.
I'm not, something software is!
Richard's postings appear to have a date 24 hours ahead of their
NNTP-Posting-Date.
--
Ian Collins.
Ian Collins said:
Richard Heathfield wrote:
<snip>
>In my view (er, literally!), [Ian Collins] is mistaken.
I'm not, something software is!
Richard [Harter]'s postings appear to have a date 24 hours ahead of
their NNTP-Posting-Date.
Ian, I spoke too soon and I owe you an apology.
Here is an extract from a Richard Harter header - in fact, it's taken
from the same header that he quoted himself in an effort to defend his
system:
NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
From: cr*@tiac.net (Richard Harter)
Newsgroups: comp.lang.c
Subject: Re: Measuring running time in a general + portable way
Date: Thu, 26 Apr 2007 13:22:00 GMT
The discrepancy between NNTP-Posting-Date and the apparent date is very
evident.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
Richard Harter wrote:
On Thu, 26 Apr 2007 20:29:03 +1200, Ian Collins <ia******@hotmail.comwrote:
>Richard Harter wrote:
>>On Thu, 26 Apr 2007 19:01:11 +1200, Ian Collins <ia******@hotmail.comwrote:
These posts show up here, converted to local time, as:
3:01 AM
3:27 PM
4:29 AM
5:16 PM
which smells like a 12 hour displacement in your time setting.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline.net
--
Posted via a free Usenet account from http://www.teranews.com
Richard Harter wrote:
CBFalconer <cb********@yahoo.comwrote:
>Richard Harter wrote:
>>> NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
Your clock is in serious error.
Huh???
Apologies. I misread the day.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline.net
--
Posted via a free Usenet account from http://www.teranews.com
Richard Heathfield wrote, On 26/04/07 11:59:
Ian Collins said:
>Richard Heathfield wrote:
<snip>
>>In my view (er, literally!), [Ian Collins] is mistaken.
I'm not, something software is!
Richard [Harter]'s postings appear to have a date 24 hours ahead of their NNTP-Posting-Date.
Ian, I spoke too soon and I owe you an apology.
Here is an extract from a Richard Harter header - in fact, it's taken
from the same header that he quoted himself in an effort to defend his
system:
NNTP-Posting-Date: Wed, 25 Apr 2007 20:22:21 -0500
From: cr*@tiac.net (Richard Harter)
Newsgroups: comp.lang.c
Subject: Re: Measuring running time in a general + portable way
Date: Thu, 26 Apr 2007 13:22:00 GMT
The discrepancy between NNTP-Posting-Date and the apparent date is very
evident.
I suggest checking the timezone on the machine, AM/PM and the date. The
Date header says the time is in GMT and I don't think Richard Harter is
in a country using GMT as its timezone.
13:22 - 5:00 gives us 8:00 (I got the -5 from the offset on the posting
date).
An AM/PM error deals with the difference between 8:22 and 20:22.
--
Flash Gordon
On Thu, 26 Apr 2007 06:57:45 -0400, CBFalconer <cb********@yahoo.com>
wrote:
>Richard Harter wrote:
>On Thu, 26 Apr 2007 20:29:03 +1200, Ian Collins <ia******@hotmail.comwrote:
>>Richard Harter wrote: On Thu, 26 Apr 2007 19:01:11 +1200, Ian Collins <ia******@hotmail.comwrote: These posts show up here, converted to local time, as:
3:01 AM
3:27 PM
4:29 AM
5:16 PM
which smells like a 12 hour displacement in your time setting.
And so it is. Until I just changed it, it read 10:47 PM. It should be
okay now. Blush, blush.
Thanks muchly, everyone.
Richard Heathfield wrote:
>
Ian, I spoke too soon and I owe you an apology.
I think I've just found my new sig :)
--
Ian Collins.
CBFalconer <cb********@yahoo.comwrote:
Richard Harter wrote:
On Thu, 26 Apr 2007 20:29:03 +1200, Ian Collins <ia******@hotmail.comwrote:
Richard Harter wrote: On Thu, 26 Apr 2007 19:01:11 +1200, Ian Collins <ia******@hotmail.comwrote:
These posts show up here, converted to local time, as:
3:01 AM
3:27 PM
4:29 AM
5:16 PM
which smells like a 12 hour displacement in your time setting.
Another proof that the 24-hour clock is superior to your poncy USAnian
12-hour one...
Richard, g,d,rlb
On Apr 25, 5:52 pm, upperclass <thammak...@gmail.comwrote:
I'm trying to find a decent way of measuring the running time of a
long-running program.
Say, the running time ranges from several seconds to more than a day.
The standard clock() function seems inadequate for this task.
(I read somewhere in this group that clock_t would likely overflow
after <1 hour).
Is there any better solution that can deal with this and be portable?
Well not really, but if overflow is your highest priority, then
#include <limits.h>
#include <time.h>
double monotimer (void (*something) (void * p), void * p) {
double dt, cdt;
time_t start = time (NULL), end;
clock_t cstart = clock(), cend;
something (p); /* Whatever you are timing */
dt = difftime (end = time (NULL), start);
cdt = (cend = clock ()) - cstart;
ock must have wrapped around (via difftime()) and simply offset that
to the clock difference (after casting to a large enough type, like
double or
if (dt >= floor (((double) ULONG_MAX) / CLOCKS_PER_SEC)) return
dt;
return cdt / (double) CLOCKS_PER_SEC;
}
So after around 50 days of running time you will switch from cycle
timer to wall clock time on Unix systems. On Windows both just
measure wall clock time in different units. So on Windows you could
do more by trying to calculate how many times the clock wrapped around
(after casting it to a double or an int64_t).
--
Paul Hsieh http://www.pobox.com/~qed http://bstring.sf.net/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jonas Kölker |
last post by:
Hello.
I'm doing a Rubik's Cube timer, so I need a function to measure 100ths of
a second. I've browsed through the library reference of python.org, but I
didn't find anything that struck me as...
|
by: Matthew Nuzum |
last post by:
We've had a chance to talk to some of our competitors who have recently gone
out of business. One of the major failings that contributed to their
collapse was not accurately understanding how much...
|
by: Dominik Wallner |
last post by:
Hi!
I'm currently implementing a program which measures voltages through an
external USB-AD-converter. It should output those values as time/voltage
pairs.
My problem is to measure the time...
|
by: smnoff |
last post by:
I have searched the internet for malloc and dynamic malloc; however, I still
don't know or readily see what is general way to allocate memory to char *
variable that I want to assign the substring...
|
by: artifact.one |
last post by:
It'd be really pleasant (in my opinion) if the next revision of the
C language actually allowed some portable control over data
alignment.
Compiler-specific mechanisms for this stuff are so...
|
by: upperclass |
last post by:
Hi,
I'm trying to find a decent way to measure program running time.
I know clock() is probably the standard way of doing it but clock_t
overflows too quickly.
The target program running time...
|
by: Ross |
last post by:
I'm a newbie at this, and have searched a lot but can't find something
that seems appropriate for measuring a recurring elapsed time.
Creating an object with: var mydate = new Date(); seems...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
| |