[ pycrypto-Bugs-627645 ] measureTickSize() can fail from low res
"SourceForge.net" <[email protected]> Mon, 10 Mar 2003 11:55:08 -0800
| Newsgroups | gmane.comp.python.cryptography.cvs |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #627645, was opened at 2002-10-23 15:01
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=627645&group_id=20937
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: A.M. Kuchling (akuchling)
Summary: measureTickSize() can fail from low res
Initial Comment:
if the resolution is really low, this function failed to find a
valid interval. here's how i fixed it.
def _measureTickSize(self):
# _measureTickSize() tries to estimate a rough
average of the
# resolution of time that you can see from
Python. It does
# this by measuring the time 100 times,
computing the delay
# between measurements, and taking the median
of the resulting
# list.
interval = [0] * 100
# Compute 100 differences
t=time.time()
for i in range(0,100):
t2=time.time()
delta=int((t2-t)*1e6)
t=t2
if delta: interval[i] = delta
# Take the median of the array of intervals
avg = reduce(lambda x, y: x+y, interval)
avg = ((avg+1)/len(interval))+1
self._ticksize=avg
----------------------------------------------------------------------
>Comment By: A.M. Kuchling (akuchling)
Date: 2003-03-10 14:55
Message:
Logged In: YES
user_id=11375
Believed fixed in 1.9alpha5.
----------------------------------------------------------------------
Comment By: Robert Olson (olson)
Date: 2002-11-06 11:29
Message:
Logged In: YES
user_id=20112
I ran into this as well on Windows. My solution was to
use time.clock()
instead of time.time() on windows;
time.clock() uses the windows hires
clocks and works great for this.
I've submitted patch 634515 for this.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=627645&group_id=20937
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf