summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2013-08-22 04:23:07 -0300
committerLucas De Marchi <lucas.demarchi@intel.com>2013-09-25 02:03:17 -0300
commitd88090ed6da733a9e7feee1d7ae74a4fffb13749 (patch)
tree320c592cc3e3f6288ae425ce34125ce2b1dad7ad
parent96c87a4bb67d78d90108d876fabc08d4ee37c25f (diff)
downloadkmod-d88090ed6da733a9e7feee1d7ae74a4fffb13749.tar.gz
Add script to create performance table
-rwxr-xr-xscripts/createtable-timing77
1 files changed, 77 insertions, 0 deletions
diff --git a/scripts/createtable-timing b/scripts/createtable-timing
new file mode 100755
index 0000000..c43cfc7
--- /dev/null
+++ b/scripts/createtable-timing
@@ -0,0 +1,77 @@
+#!/usr/bin/python
+import argparse
+import os.path
+import sys
+import numpy as np
+
+def parse_table(f):
+ x = []
+ y = []
+ for line in f:
+ if len(line) < 2 or not line[0].isdigit():
+ continue
+
+ val = line.split()[0:2]
+ x += [int(val[0])]
+ y += [float(val[1])]
+
+ return x, y
+
+parser = argparse.ArgumentParser()
+parser.add_argument('--groups', nargs=1, default=8)
+parser.add_argument('file', nargs='*')
+args = parser.parse_args()
+
+t = []
+for fn in args.file:
+ with open(fn) as f:
+ x, y = parse_table(f)
+ t += [(x, y)]
+
+
+mx = t[0][0][-1]
+mn = t[0][0][0]
+sz = (mx - mn) / args.groups
+
+cur = mn
+groups=[]
+for g in range(0, args.groups):
+ try:
+ c = groups[-1][1] + 1
+ except:
+ c = mn
+ groups += [tuple([c, int(round(cur + sz, 0))])]
+ cur += sz;
+
+
+idx = []
+for g in groups:
+ x = t[0][0]
+ a = 0
+ b = 0
+ for i in x:
+ if i >= g[0]:
+ a = x.index(i)
+ break
+
+ for i in x[a:]:
+ if i >= g[1]:
+ b = x.index(i)
+ break
+
+ idx += [tuple([a, b])]
+
+#print(groups)
+#print(idx)
+
+
+
+print('{:<10s}{:>8s}{:>8s}'.format('keylen', 'before', 'after'))
+for g in zip(groups, idx):
+ i = g[1]
+ a = np.mean(t[0][1][i[0]:i[1]])
+ b = np.mean(t[1][1][i[0]:i[1]])
+
+ print('{:<10s}'.format('%u-%u' % (g[0][0], g[0][1])), end='')
+ print('{:>8.1f}{:>8.1f}'.format(a, b), end='')
+ print(' ({:.2f}%)'.format(((b - a)/a) * 100))