A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://bytes.com/topic/python/answers/527849-time-clock-going-backwards below:

time.clock() going backwards?? - Post.Byes

Hello,

I experimented something very strange, a few days ago. I was debugging an

application at a customer's site, and the problem turned out to be that

time.clock() was going "backwards" , that is it was sometimes (randomically)

returning a floating point value which was "less than" the value returned by

the previous invokation. The computer was a pretty fast one (P4 3Ghz I think,

running Windows XP), and this happened only between very close invokations of

time.clock().

I have triple-verified this, including printing the repr() of the floating

point number and verifying it was really minor than the previous value by a few

microseconds. In other words, I'm absolutely positive that it's not a mistake

on my side, but that time.clock() was really apparently "jumping backward".

This was confusing the hell out of my application, of course, and I just hacked

it so to ignore these bogus reads, and just reading off again. Since the error

was just of a few microseconds, reading time.clock() again produces a number

which was higher than what I had before, and thus OK for my application.

I was wondering if someone had experimented this behaviour before. I tried

googling but to no effect. Is it possible this to be a bug in Python itself

(maybe, shooting at the moon, in the conversion between the 64bit performance

counter and the floating point representation returned by time.clock()), or

could it be a bug in Windows itself or the mother board drivers (buf if so,

wouldn't other application start going mad)?

--

Giovanni Bajo


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4