]> git.llucax.com Git - software/dgc/dgcbench.git/blobdiff - stats.py
Add a helper script to improve accuracy when benchmarking
[software/dgc/dgcbench.git] / stats.py
index fc08dd3f18c70831d65b9f55a6ca96c00badd634..0008fe99aa9c438e648296215e9f7e3d4d13afc8 100755 (executable)
--- a/stats.py
+++ b/stats.py
@@ -1,12 +1,34 @@
 #!/usr/bin/env python
 
+import re
 import sys
 import numpy.numarray.mlab as m
 
+exp = '$1'
+fmt = '%(min)s,%(mean)s,%(max)s,%(std)s'
+sep = ','
+
+try:
+       exp = sys.argv[1]
+       fmt = sys.argv[2]
+       sep = sys.argv[3]
+except:
+       pass
+
 vals = []
-for l in sys.stdin:
+for n, l in enumerate(sys.stdin):
        l = l.strip()
-       if l:
-               vals.append(float(l))
-print '%s,%s,%s,%s' % (min(vals), m.mean(vals), max(vals), m.std(vals))
+       if not l:
+               continue
+       try:
+               fields = dict([('$'+str(int(k)+1), float(v.strip()))
+                               for k, v in enumerate(l.split(sep))])
+               v = float(eval(re.sub(r'(\$\d+)', r'%(\1)f', exp) % fields))
+       except:
+               if n == 0:
+                       continue
+               raise
+       vals.append(v)
+vars = dict(min=min(vals), mean=m.mean(vals), max=max(vals), std=m.std(vals))
+print fmt % vars