Mercurial > code > home > repos > light9
diff light8/updatefreq.py @ 120:b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
new modules: dmxclient provides a very convenient way for clients to talk to the
dmxserver; updatefreq stores event times and computes a report about how frequently
they occur
author | drewp |
---|---|
date | Fri, 13 Jun 2003 14:00:36 +0000 |
parents | 45b12307c695 |
children | 57809e0ef359 |
line wrap: on
line diff
--- a/light8/updatefreq.py Fri Jun 13 13:59:32 2003 +0000 +++ b/light8/updatefreq.py Fri Jun 13 14:00:36 2003 +0000 @@ -9,7 +9,7 @@ the samples param to __init__ specifies how many past updates will be stored. """ - def __init__(self,samples=20): + def __init__(self,samples=40): self.times=[0] self.samples=samples @@ -24,10 +24,7 @@ """a cheap algorithm, for now, which looks at the first and last times only""" - try: - hz=len(self.times)/(self.times[-1]-self.times[0]) - except ZeroDivisionError: - return 0 + hz=len(self.times)/(self.times[-1]-self.times[0]) return hz def __str__(self): - return "%.2fHz"%float(self) + return "%.1fHz"%float(self)