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 1851
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: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| |