f



time.time() strangeness

Hello,

today I encountered a very odd situation. I am on Windows Vista and usin=
g  =

Python 2.5.2. Here's a code snippet to illustrate my problem:

# uncomment the next line to trigger the problem
# myExtensionModule.CreateDirect3D9Device()
import time
for i in range(0,100):
     print time.time()

With the line commented time.time() returns a changing value which is wh=
at  =

I expect. However, when I uncomment it and create a Direct3D9 Device  =

[1][2] it keeps printing the very same number over and over! In my proje=
ct  =

I am using twisted which uses time.time() to schedule all calls. Since  =

time.time() is completely screwed the whole application breaks.
I took a look at [3], but I can't see any obivous way how this all  =

interacts. Specifically I am not sure which API time.time() uses  =

internally (timeGetTime maybe?). Knowing this could probably help me deb=
ug  =

more. I feel like time.time() should not break (unless the vid card  =

driver/directx has a major bug). Any idea what might be happening here?
Replacing time.time() with time.clock() in twisted.python.runtime makes =
 =

the problem disappear. I guess because it uses QueryPerformanceCounter.

Thanks for your time,
-Matthias

References:
[1] http://msdn2.microsoft.com/en-us/library/bb172527(VS.85).aspx
[2] http://msdn2.microsoft.com/en-us/library/bb172527(VS.85).aspx
[3]  =

http://svn.python.org/view/python/trunk/Modules/timemodule.c?rev=3D59678=
&view=3Dmarkup
0
nitro1 (6)
2/26/2008 7:37:22 PM
comp.lang.python 77058 articles. 6 followers. Post Follow

1 Replies
1155 Views

Similar Articles

[PageSpeed] 36

Nitro <nitro@dr-code.org> writes:
> With the line commented time.time() returns a changing value which is
> what  I expect. However, when I uncomment it and create a Direct3D9
> Device  [1][2] it keeps printing the very same number over and over!

The granularity of time.time can be quite large, maybe as much
as 1 second in some systems.  Also, if the user can set the time,
the output might not be monotone.  They might set the clock backwards
if it has drifted ahead, or something like that.  Better to use an
explicit counter if you need a monotonically increasing sequence.
0
phr.cx (5493)
2/26/2008 7:44:44 PM
Reply:

Similar Artilces:

time.time or time.clock
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. if time.clock() - time.clock() < time.time() - time.time(): clock = time.clock else: clock = time.time Will this work most of the time, or is there something better? Ron On Jan 14, 7:05 am, Ron Ad...

time.clock() or time.time()
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 0.0133562088013, 0.00669002532959 etc. To me it looks like time.time() gives a better measure (at least from a statistical practical point of view). peterb...

time.time()
am I doing this wrong: print (time.time() / 60) / 60 #time.time has been running for many hours if time.time() was (21600/60) then that would equal 360/60 which would be 6, but I'm not getting 6 so I'm not doing the division right, any tips? On Sat, 24 Jan 2004 13:01:40 -0500, Bart Nessux <bart_nessux@hotmail.com> wrote: >am I doing this wrong: > >print (time.time() / 60) / 60 #time.time has been running for many hours > >if time.time() was (21600/60) then that would equal 360/60 which would >be 6, but I'm not getting 6 so I'm not doing the divisi...

Is time.time() < time.time() always true?
So, I was blazin' some mad chronix, as they say, and got on to thinking about Python. The question was, is the statement: time.time() < time.time() always true? Seems it should be false, since the statement itself occurs at one time instant.. but of course we know that python doesn't execute code that way.. So my question is, why doesn't Python work this way? (PS, I wasn't smoking anything, its a figure of speech :) ) On 21 Nov 2006 15:10:25 -0800, flamesrock <flamesrock@gmail.com> wrote: > So, I was blazin' some mad chronix, as they say, and got on to th...

time.time() strangeness #4
Ok, my final solution is to add the D3DCREATE_FPU_PRESERVE flag. It didn't harm performance in a noticeable way at all. I was under the impression SSE would be affected by this, too. Additionally I was under the impression that float precision would suffice for time.time(). Obviously I was blatantly wrong :-) Thanks to Gabriel, Ross and Roel for commenting on this and sharing their insights! They should really make the fpu preserve flag the default. It just causes very sneaky bugs. -Matthias Nitro <nitro@dr-code.org> wrote: >They should really make the fpu preserve...

time.time() strangeness #3
> Nevertheless time.time() shouldn't fail here unless DirectX is really > badly tinkering with my system. I can tell you more now. If I pass D3DCREATE_FPU_PRESERVE while creating the DirectX device the bug does not appear. This flag means "Direct3D defaults to single-precision round-to-nearest" (see [1]) mode. Unfortunately it is not an option to pass this flag, I need the performance boost it gives. Can somebody tell me how this interacts with python's time.time()? I suppose it's some kind of double vs. float thing or some fpu asm code issue... -Matt...

time.time() strangeness #2
> The granularity of time.time can be quite large, maybe as much > as 1 second in some systems. Also, if the user can set the time, > the output might not be monotone. They might set the clock backwards > if it has drifted ahead, or something like that. Better to use an > explicit counter if you need a monotonically increasing sequence. It's not the granularity, after all it works without the single CreateDevice. With the line uncommented the value doesn't even change after 2 minutes. I am not sure what you mean with explicit counter. I think I would still need...

RE: Is time.time() < time.time() always true?
Chris Mellon wrote: > On 21 Nov 2006 15:10:25 -0800, flamesrock <flamesrock@gmail.com> > wrote:=20 >> So, I was blazin' some mad chronix, as they say, and got on to >> thinking about Python.=20 >>=20 >> The question was, is the statement: >>=20 >> time.time() < time.time() >>=20 >> always true? Seems it should be false, since the statement itself >> occurs at one time instant.. but of course we know that python >> doesn't execute code that way.. So my question is, why doesn't >> Python work this way?=...

time in milliseconds by calling time.time()
I am trying to measure some system response time by using the time.time () or time.clock() in my script. However, the numbers I get are in 10s of milliseconds. For example, 1248481670.34 #from time.time() 0.08 #from time.clock() That won't work for me, since the response time may be only a few milliseconds. My environment is Solaris 10 with Python 2.4.4 (#7, Feb 9 2007, 22:10:21). SunOS 5.10 Generic_137112-07 i86pc i386 i86pc The tricky thing is, if I run the python interpreter and import the time module, I can get a time floating number in better precision by cal...

delta time = time stop
I'm using Python to parse a bunch of s/w test files and make csv files for later report generation by MS ACCESS....(my boss loves the quick turn-around compared to C). Each log file may contain one or more 'sessions', and each session may contain one or more 'nodes'. Each session in the log has an ASCII start and stop time, as does each node. I have the basic parse part done for parameters, errors, etc., but noticed my routine for determining how long each session/node took (delta time) was a bit repetitive, so decided to make a 'stand-alone' routine to handle th...

Timing run time
I would like to compare the speed of two algorithms solving the same problem. As far as I understood, the tic-toc command gives the time difference between the beginning and the end of the computation, without taking into account the time spent by the processor doing something else. I'm using a multi-processor multi-users machine and the CPU time used by my process is not 100% and is not constant. The measured speeds are fluctuating so much that I can hardly conclude anything. Is it possible to obtain realistic measurements of the speed of my algorithms? Thanks for your help Dear Didi...

Time Divided by Time is What?
I thought a time quantity divided by a time quantity would be a real, but it seems to be an integer. Can anyone confirm that? I can't find a reference that discusses this. Rick On Saturday, November 17, 2012 7:12:31 PM UTC-5, rickman wrote: > I thought a time quantity divided by a time quantity would be a real, but it seems to be an integer. Can anyone confirm that? I can't find a reference that discusses this. Rick Yes, time/time is an integer. If you need more precision than integer than you can do something like this as an example... real(time/1ps)/1E12 Kevi...

covert standard time (AMPM time) to Military time
What is the best way to covert standard time (AMPM time) to Military time? data test; input @1 mytime 5.; @6 ampm $2.; cards; 04:20AM 07:30PM 05:27AM 00:00PM 01:00AM 12:49AM 12:59PM ; run; Hi Lee, Try this... data test; input @1 mytime $ 5. @6 ampm $2.; new=compress(mytime||ampm); new_var=input(new,time8.); format new_var time.; cards; 04:20AM 07:30PM 05:27AM 00:00PM 01:00AM 12:49AM 12:59PM ; run; On Feb 12, 1:22=A0am, hummingbird10...@HOTMAIL.COM (Annie Lee) wrote: > What is the best way to covert standard time (AMPM time) to Military time= ? > > data test; > input >...

convert time in and time out
hi all, because I have a list of data that contains Clock_in and Clock_out, how can I know the total hours that have been used where I have converted it to Clock_in at 46200 and Clock_out at 48061 how can I know the total hours that have been used? by the way, did I need to create two new data to merge togather Thanks Not sure what you have or did. If those numbers represent the number of seconds since midnight, and you don't have any in and out combinations that span across midnight, you could use something like: data have; input clock_in clock_out; format x y time.; hours=3D(c...

convert time string in UTC to time in local time
I'm guessing there is an easy way to do this but I keep going around in circles in the documentation. I have a time stamp that looks like this (corresponding to UTC time): start_time = '2007-03-13T15:00:00Z' I want to convert it to my local time. start_time = time.mktime(time.strptime(start_time, '%Y-%m-%dT%H:%M: 00Z')) start_time -= time.timezone This was working fine now, but if I do it for a date next week (such as March 13th in the above example), it breaks because my local time moves to daylight savings time this weekend. So my time is now off by an hour....

Times Returned by TIME()
I would have posted this on the Quicksilver group but couldn't find it. We have a Quicksilver system that picks up files from a Windows eftpos application. There have been some slowdowns in the process and we've added some logging to identify the culprit. When the QS app detects a file, it writes a log record using time derived from TIME(). It shells out to a Clipper app which returns ADIR() data on the file. What we are finding on the test PC (XP) is that the ADIR() time of the file is approximately 2 seconds later than the TIME() value recorded. Does anyone have an explanation? Th...

Time + time.local
Hi - I cant seem to get localtime to work, can anyone share some gotchas? ## check environment is setup [dc@fox:~]$ echo $TZ Japan/Tokyo [dc@fox:~]$ irb irb(main):001:0> ENV['TZ'] => "Japan/Tokyo" # so the env is coming through ok... or is it? irb(main):021:0> u=Time.now.utc => Tue Jan 04 06:21:25 UTC 2011 irb(main):019:0> t1=Time.now.localtime => Tue Jan 04 06:21:02 +0000 2011 irb(main):020:0> t1.zone => "UTC" ### so it seems zone is being ignored # is there any way to override/forcibly set the timezone? ir...

Which To Use
Is Times the standard serif font? I'm deciding which font to use for a book I'm writing. My printer, HP 4ML PostScript, has the resident PostScript font Times Roman (strangely, the bold, italic and bold italic are Times). I recall that PageMaker 5 pushed for using Times. I now have PageMaker 7, and in its font list (the same list that appears in any application) is Times and Times New Roman. Would appreciate your explanation as to how resident printer fonts relate to whatever font I select from the font list (these are usually True Type, although there are other kinds). Also, a recomme...

convert time to ruby time to calculate the time difference.
Hi all, I have following two time stamps, 12:35:10:757 & 12:35:10:759 I want to convert them to ruby time and find the time difference. which is a 2 micro seconds. I would appreciate any help.. thanks in advance -- Posted via http://www.ruby-forum.com/. Il 20/09/10 17.21, Ruwan Budha ha scritto: > Hi all, > > I have following two time stamps, > > 12:35:10:757& 12:35:10:759 > > I want to convert them to ruby time and find the time difference. > > which is a 2 micro seconds. > Simply: require 'time' mT=T...

time sync? time servers give wrong time
I'm in toronto. Eastern Standard time. I use netdate linux to sync my clock. I use: /usr/sbin/netdate -l 2 localhost 193.67.79.202 216.46.5.9 This was working fine until last week when the DST changed. Now it reports one hour behind. Every name server does this. For example: localhost +0.000 Thu Mar 13 19:17:51.519 193.67.79.202 -0.669 Thu Mar 13 19:17:51.000 216.46.5.9 -0.718 Thu Mar 13 19:17:51.000 Local host firewall has best time, so not setting date localhost +0.000 Thu Mar 13 19:17:51.718 But its 20:17 right now in EST. How do I f...

Time Of Day From a time
Anyone know how to calulacute the time of day, ie hour 1-24 for a time stored in a database, using just a time in a record??? Dennis Mason N6PDB dennis@bonnydoonfire.org shit wrote: > Anyone know how to calulacute the time of day, ie hour 1-24 for a time > stored in a database, using just a time in a record??? > > Dennis Mason > N6PDB > dennis@bonnydoonfire.org If you stored the time value as a DateTime data type, you can display it in 24hr time using the Format() function: Format(time_column,"hh") In Debug window: ? format(now(),"hh") ...

?TIME????????????????=/=/=/TIME?????? ?j???=/=/=/??????????
&#x2665;TIME&#x2467;&#x2461;&#x318D;&#x421;&#x41E;&#x41C;&#xC778;&#xD130;&#xB137;&#xD1A0;&#xD1A0;&#xBCA0;&#xD305;&#xC0AC;&#xC774;&#xD2B8;=/=/=/TIME&#x2467;&#x2461;&#x318D;&#x421;&#x41E;&#x41C; &#x261C;j&#x397;&#x2665;&#x261E;=/=/=/&#xC778;&#xD130;&#xB137;&#xD1A0;&#xD1A0;&#xBCA0;&#xD305;&#xC0AC;&#xC774;&#xD2B8; &#x2665;TIME&#x2467;&#x2461;&#x318D;&#x421;&#x41E;&#x41C;&#xC778;&#xD130;&#xB137;&#xD1A0;&#...

timing and timing reports (again)
hi ich have question about timing. i have an edk design with microblaze (using spartan 3e 500) where i use an ip core that i wrote myself. when i implement the design i get the following timing output in my console. ------------------------------------------------------------------------------------------------------ Constraint | Check | Worst Case | Best Case | Timing | Timing | | Slack | Achievable | Errors | Score -------------------------------------------------------------------------------...

server time != my time
on a timestamp, what's the best way to make the timestamp show as my time, rather than the server's time? i.e., it is 10:49 am here but the code on the server will create a timestamp of 2:49 pm. I want it to be stamped as 10:49 am Herb wrote: > on a timestamp, what's the best way to make the timestamp show as my > time, rather than the server's time? > > i.e., it is 10:49 am here but the code on the server will create a > timestamp of 2:49 pm. I want it to be stamped as 10:49 am Take a look at: http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html ...

Web resources about - time.time() strangeness - comp.lang.python

Strangeness - Wikipedia, the free encyclopedia
This article is about a concept in particle physics. For the definition of "strangeness", see wikt:strangeness . For other uses, see Strange ...

Google Strangeness - Flickr - Photo Sharing!
More at www.seroundtable.com/archives/016854.html

SOTT Summary - December 2014: Extreme Weather, Earth Changes, Fireballs, High Strangeness - YouTube
The twelfth installment in our monthly series, the following video compiles footage of 'signs of the times' from around the world during December ...

New research highlights strangeness of the Australian Water Dragon
Perhaps it's because the world of human behaviour is so shocking that this column turns so often to topics of blameless wildlife.

The Strangeness Of Our Love Of Our Pets, Ctd
A reader is moved by this post : I have sat in the waiting room of my vet’s office three times a week for the last two months, waiting while ...

Op-ed: The shocking strangeness of our 25-year-old digital privacy law
If the government needs a warrant to search your home computer, why doesn't it …

Late Night Open Thread: Great Strangeness
dang penn and teller look like shit these days pic.twitter.com/4X4AxB8KBS — Adam Weinstein (@AdamWeinstein) April 22, 2015 Buzzfeed attempts ...

Apple: Look Past Strangeness, Watch is Future of IoT, Says Oppenheimer
Oppenheimer & Co.’s Andrew Uerkwitz this morning reiterates an Outperform rating on shares of Apple (AAPL), and a $155 price target, writing ...

Victorian Strangeness: The bizarre tale of the ladies who limped
Author Jeremy Clay tells the The bizarre tale of the ladies who limped.

"The president has jumped into the strangeness fray by musing aloud that mandatory voting in the United ...
Writes Peggy Noonan. “It would be transformative if everybody voted,” he told an audience in Cleveland. Yes, it would. It would mean a lot of ...

Resources last updated: 2/24/2016 10:56:32 PM