]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
scripts: Add scripts to parse hashfunc timings
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 13 Aug 2013 18:39:03 +0000 (15:39 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Fri, 20 Sep 2013 19:35:52 +0000 (14:35 -0500)
scripts/parse-timing [new file with mode: 0755]
scripts/run.sh [new file with mode: 0755]

diff --git a/scripts/parse-timing b/scripts/parse-timing
new file mode 100755 (executable)
index 0000000..6676c6b
--- /dev/null
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+
+import sys
+import numpy as np
+
+CUTOFF = 0.8
+
+
+def trimvalues(values, cutoff):
+    sv = sorted(values)
+    n = round(len(values) * cutoff)
+
+    if n <= 2:
+        return sv
+
+    var = []
+    for i in range(len(values) - n):
+        var += [np.std(sv[i:n + i])]
+
+    i = var.index(min(var))
+    return sv[i:n + i]
+
+
+def parse_file(f):
+    val = dict()
+    while True:
+        line = f.readline().split()
+        if len(line) < 2 or not line[0].isdigit():
+            break
+        x = int(line[0])
+        y = float(line[1])
+
+        if x in val:
+            val[x] += [y]
+        else:
+            val[x] = [y]
+
+    x = []
+    y = []
+    s = []
+    n = []
+    for k, v in sorted(val.items()):
+        v = trimvalues(v, CUTOFF)
+        x += [k]
+        y += [np.mean(v)]
+        s += [np.std(v)]
+        n += [len(v)]
+
+    return x, y, s, n
+
+print("# cutoff: %.2f" % CUTOFF)
+print("# len mean stddev nelemen")
+
+if len(sys.argv) > 1:
+    filename = sys.argv[1]
+else:
+    filename = "/dev/stdin"
+
+with open(filename) as f:
+    x, y, s, n = parse_file(f)
+    for i in zip(x, y, s, n):
+        print("%d %.2f %.2f %d" % (i[0], i[1], i[2], i[3]))
diff --git a/scripts/run.sh b/scripts/run.sh
new file mode 100755 (executable)
index 0000000..504c6a6
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+log="$1"
+
+for ((i=0; i < 10;))
+do
+    err=${log}.${i}.stderr
+    sudo chrt -f 99 /usr/bin/time -f \
+        "\n***\ntime: %E\ncontext switches: %c\nwaits: %w" \
+        tools/depmod -a > ${log}.$i 2>$err
+    [[ ! -z "$(grep 'context switches: 0' $err)" ]] && ((i++))
+done
+
+rm ${log}.0*
+cat "$log".* | scripts/parse-timing > $log
+rm ${log}.*