From b78d6f097f85aa41f384a0f0922c98c58a22c879 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Tue, 25 Aug 2015 23:11:08 +0200 Subject: stats can now be calculated over multiple files. readme. --- README | 3 +++ stats.py | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README b/README index ad6b58a..fa3410e 100644 --- a/README +++ b/README @@ -10,3 +10,6 @@ s = lock input. toggle between "user controls" and "bot controls". hold shift fo move mouse = move mouse left/mid/right click: set markers (currently unused) esc = quit + +the stats.py module automatically creates/overwrites the stats.pickle file (roughly 1MB per 5 minutes currently) +which can be loaded using Stats.load() and analyzed using the Stats.analyze_* functions, or using analyze.py diff --git a/stats.py b/stats.py index be8b547..3856c64 100644 --- a/stats.py +++ b/stats.py @@ -117,6 +117,21 @@ class Stats: def load(filename): return Stats(None, pickle.load(open(filename,"rb"))) + def merge(self, filename): + data2 = pickle.load(open(filename,"rb")) + self.data.min_mass = min(self.data.min_mass, data2.min_mass) + self.data.max_mass = max(self.data.max_mass, data2.max_mass) + + for i in data2.size_vs_visible_window: + self.data.size_vs_visible_window[i] += data2.size_vs_visible_window[i] + for i in data2.mass_vs_visible_window: + self.data.mass_vs_visible_window[i] += data2.mass_vs_visible_window[i] + + for i in data2.size_vs_speed: + for j in data2.size_vs_speed[i]: + self.data.size_vs_speed[i][j] += data2.size_vs_speed[i][j] + + def analyze_speed(self): results=[] @@ -125,7 +140,7 @@ class Stats: average = quantile(values, 0.5) maximum = quantile(values, 0.8) - results += [(size,maximum,average,minimum,False,False,False,len(values))] + results += [(size,maximum,average,minimum,False,False,False,sum(values.values()))] # mark outliers for i in range(1, len(results)-1): @@ -145,8 +160,9 @@ class Stats: coeff_vs_stddev += [(coeff, avg(products), stddev(normalize(products)))] best = min(coeff_vs_stddev, key=lambda v:v[2]) - print("size**"+str(best[0])+" * speed = "+str(best[1]) ) print("size\tcalc\tmax\tavg\tmin\t\tndata") for size, maximum, average, minimum, maxoutlier, avgoutlier, minoutlier, ndata in results: print(str(size) + ":\t" + "%.1f" % (best[1] / size**best[0]) + "\t" + ("*" if maxoutlier else "") + str(maximum) + "\t" + ("*" if avgoutlier else "") + str(average) + "\t" + ("*" if minoutlier else "") + str(minimum) + "\t\t" + str(ndata)) + + print("size**"+str(best[0])+" * speed = "+str(best[1]) ) -- cgit v1.2.3