Re: Calculating Elapsed Time

2005-12-07 Thread Grant Edwards
On 2005-12-08, Bengt Richter <[EMAIL PROTECTED]> wrote: >>We're seeing floating point representation issues. >> >>The resolution of the underlying call is exactly 1us. Calling >>gettimeofday() in a loop in C results in deltas of exactly 1 or >>2 us. Python uses a C double to represent time, an

Re: Calculating Elapsed Time

2005-12-07 Thread Bengt Richter
On Wed, 07 Dec 2005 18:32:50 -, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2005-12-07, Fredrik Lundh <[EMAIL PROTECTED]> wrote: ... >> if I keep running the script over and over again, I do get individual >> >> -1.19209289551e-06 >> >> items from time to time on both machines... > >We're see

Re: Calculating Elapsed Time

2005-12-07 Thread Grant Edwards
On 2005-12-07, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> import time >> for i in range(10): >> print time.time()-time.time() >> >> After the first loop, I usually get one of three values: >> >> 3.099us, 2.14,us, 2.86us. > > I get two different values: > > -1.90734863281e-06 > -2.1457672119

Re: Calculating Elapsed Time

2005-12-07 Thread Peter Hansen
Peter Hansen wrote: > Fredrik Lundh wrote: >>Peter Hansen wrote: >>>Going by memory, Linux will generally be 1ms resolution (I might be >>>off by 10 there...), while Windows XP has about 64 ticks per second, >>>so .015625 resolution... > >>if I run this on the Windows 2K box I'm sitting at right n

Re: Calculating Elapsed Time

2005-12-07 Thread Fredrik Lundh
Grant Edwards wrote: > > Yeah, I said it was silly. On the other hand, the Linux box is a lot faster > > than the Windows box I'm using, and I do get the same result no matter > > what Python version I'm using... except if I run it under my latest 2.4 build, where I get 524288 ... > > > > (and

Re: Calculating Elapsed Time

2005-12-07 Thread Christopher Subich
Fredrik Lundh wrote: > if I run this on the Windows 2K box I'm sitting at right now, it settles > at 100 for time.time, and 1789772 for time.clock. on linux, I get 100 > for time.clock instead, and 262144 for time.time. Aren't the time.clock semantics different on 'nix? I thought, at least on

Re: Calculating Elapsed Time

2005-12-07 Thread Christopher Subich
Peter Hansen wrote: > A few things. > > 1. "Precision" is probably the wrong word there. "Resolution" seems > more correct. > > 2. If your system returns figures after the decimal point, it probably > has better resolution than one second (go figure). Depending on what > system it is, your b

Re: Calculating Elapsed Time

2005-12-07 Thread Peter Hansen
Fredrik Lundh wrote: > Peter Hansen wrote: >>Going by memory, Linux will generally be 1ms resolution (I might be >>off by 10 there...), while Windows XP has about 64 ticks per second, >>so .015625 resolution... > [snip script] > if I run this on the Windows 2K box I'm sitting at right now, it sett

Re: Calculating Elapsed Time

2005-12-07 Thread Grant Edwards
On 2005-12-07, Grant Edwards <[EMAIL PROTECTED]> wrote: for f in range(10): > ... print t()-t() > ... > -4.05311584473e-06 > -1.90734863281e-06 > -1.90734863281e-06 > -2.14576721191e-06 > -2.86102294922e-06 > -1.90734863281e-06 > -2.14576721191e-06 > -2.14576721191e-06 > -9.53674316406e-07

Re: Calculating Elapsed Time

2005-12-07 Thread Grant Edwards
On 2005-12-07, Bengt Richter <[EMAIL PROTECTED]> wrote: >>In my experience, time.time() on Linux has a resolution of >>about 1us. The delta I get when I do >> >> print time.time()-time.time() >> >>is usually about 2-3us, but some of that is probably due to the >>overhead involved. >> > Try > > >

Re: Calculating Elapsed Time

2005-12-07 Thread Bengt Richter
On Wed, 07 Dec 2005 16:35:15 -, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2005-12-07, Peter Hansen <[EMAIL PROTECTED]> wrote: > >> 2. If your system returns figures after the decimal point, it >>probably has better resolution than one second (go figure). >>Depending on what system i

Re: Calculating Elapsed Time

2005-12-07 Thread Grant Edwards
On 2005-12-07, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >>> if I run this on the Windows 2K box I'm sitting at right now, >>> it settles at 100 for time.time, and 1789772 for time.clock. >>> on linux, I get 100 for time.clock instead, and 262144 for >>> time.time. >> >> At least under Linux, I sus

Re: Calculating Elapsed Time

2005-12-07 Thread Fredrik Lundh
Grant Edwards wrote: > >> Going by memory, Linux will generally be 1ms resolution (I might be > >> off by 10 there...), while Windows XP has about 64 ticks per second, > >> so .015625 resolution... > > > > here's a silly little script that measures the difference between > > two distinct return va

Re: Calculating Elapsed Time

2005-12-07 Thread Grant Edwards
On 2005-12-07, Grant Edwards <[EMAIL PROTECTED]> wrote: >> if I run this on the Windows 2K box I'm sitting at right now, it settles >> at 100 for time.time, and 1789772 for time.clock. on linux, I get 100 >> for time.clock instead, and 262144 for time.time. > > At least under Linux, I suspect you

Re: Calculating Elapsed Time

2005-12-07 Thread Grant Edwards
On 2005-12-07, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Peter Hansen wrote: > >> Going by memory, Linux will generally be 1ms resolution (I might be >> off by 10 there...), while Windows XP has about 64 ticks per second, >> so .015625 resolution... > > here's a silly little script that measures t

Re: Calculating Elapsed Time

2005-12-07 Thread Grant Edwards
On 2005-12-07, Peter Hansen <[EMAIL PROTECTED]> wrote: > 2. If your system returns figures after the decimal point, it >probably has better resolution than one second (go figure). >Depending on what system it is, your best bet to determine >why is to check the documentation for your sy

Re: Calculating Elapsed Time

2005-12-07 Thread Fredrik Lundh
Peter Hansen wrote: > Going by memory, Linux will generally be 1ms resolution (I might be > off by 10 there...), while Windows XP has about 64 ticks per second, > so .015625 resolution... here's a silly little script that measures the difference between two distinct return values, and reports the

Re: Calculating Elapsed Time

2005-12-07 Thread Jean Johnson
Thanks to everyone for their e-mails. I am using Fredrik's strptime/mktime solution to calculate my elapsed time. __ Yahoo! DSL – Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com -- http://mail.python.org/mailman

Re: Calculating Elapsed Time

2005-12-07 Thread Peter Hansen
malv wrote: > "Note that even though the time is always returned as a floating point > number, not all systems provide time with a better precision than 1 > second." says the doc. > Can anything be said about precision if indeed your system returns > figures after the decimal point? A few things.

Re: Calculating Elapsed Time

2005-12-07 Thread malv
"Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second." says the doc. Can anything be said about precision if indeed your system returns figures after the decimal point? Thx. malv -- http://mail.python.org

Re: Calculating Elapsed Time

2005-12-06 Thread Bengt Richter
On Tue, 6 Dec 2005 12:36:55 -0800 (PST), Jean Johnson <[EMAIL PROTECTED]> wrote: >Hello - > >I have a start and end time that is written using the >following: > >time.strftime("%b %d %Y %H:%M:%S") > >How do I calculate the elapsed time? > >>> tf1 = time.strftime("%b %d %Y %H:%M:%S") >>> tf1

Re: Calculating Elapsed Time

2005-12-06 Thread skip
Jean> I'm using an old version of python (2.1) and datetime isn't Jean> available until Python 2.3. I can't upgrade my python. There's a reference implementation of datetime written in Python: http://svn.python.org/view/sandbox/trunk/datetime/ It may or may not work in 2.1. If you

Re: Calculating Elapsed Time

2005-12-06 Thread Fredrik Lundh
Jean Johnson wrote: > I have a start and end time that is written using the > following: > > time.strftime("%b %d %Y %H:%M:%S") > > How do I calculate the elapsed time? import time FORMAT = "%b %d %Y %H:%M:%S" t1 = time.strftime(FORMAT) print t1 time.sleep(1) t2 = time.strftime(FORMAT) prin

Re: Calculating Elapsed Time

2005-12-06 Thread Jean Johnson
I'm using an old version of python (2.1) and datetime isn't available until Python 2.3. I can't upgrade my python. --- [EMAIL PROTECTED] wrote: > > Jean> How do I calculate the elapsed time? > > Where t1_s and t2_s reference time strings in the > format you describe: > > import dateti

Re: Calculating Elapsed Time

2005-12-06 Thread skip
Jean> How do I calculate the elapsed time? Where t1_s and t2_s reference time strings in the format you describe: import datetime import time fmt = "%b %d %Y %H:%M:%S" t1 = datetime.datetime(*time.strftime(t1_s, fmt)[:6]) t2 = datetime.datetime(*time.strftime(t2_s, fmt

Calculating Elapsed Time

2005-12-06 Thread Jean Johnson
Hello - I have a start and end time that is written using the following: time.strftime("%b %d %Y %H:%M:%S") How do I calculate the elapsed time? JJ __ Yahoo! DSL – Something to write home about. Just $16.99/mo. or less. dsl.yahoo.c