Mercurial > code > home > repos > light9
changeset 126:57809e0ef359
more precision on output; fewer default sample count
author | drewp |
---|---|
date | Sat, 14 Jun 2003 14:47:34 +0000 |
parents | 50001190b317 |
children | fae7751d9760 |
files | light8/updatefreq.py |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/light8/updatefreq.py Sat Jun 14 14:47:22 2003 +0000 +++ b/light8/updatefreq.py Sat Jun 14 14:47:34 2003 +0000 @@ -9,7 +9,7 @@ the samples param to __init__ specifies how many past updates will be stored. """ - def __init__(self,samples=40): + def __init__(self,samples=20): self.times=[0] self.samples=samples @@ -24,7 +24,10 @@ """a cheap algorithm, for now, which looks at the first and last times only""" - hz=len(self.times)/(self.times[-1]-self.times[0]) + try: + hz=len(self.times)/(self.times[-1]-self.times[0]) + except ZeroDivisionError: + return 0 return hz def __str__(self): - return "%.1fHz"%float(self) + return "%.2fHz"%float(self)