diff options
author | Lucas De Marchi <lucas.demarchi@intel.com> | 2013-08-13 15:39:03 -0300 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2013-09-20 14:35:52 -0500 |
commit | 68882b4861e182bcfe7af092ba2f6d822c611968 (patch) | |
tree | 00507cd2b35f329419157c27639547fc9b5adc8d | |
parent | 65fb2dc3f7cd1e3e18b9ee10703b71d628a54c9d (diff) | |
download | kmod-68882b4861e182bcfe7af092ba2f6d822c611968.tar.gz |
scripts: Add scripts to parse hashfunc timings
-rwxr-xr-x | scripts/parse-timing | 62 | ||||
-rwxr-xr-x | scripts/run.sh | 16 |
2 files changed, 78 insertions, 0 deletions
diff --git a/scripts/parse-timing b/scripts/parse-timing new file mode 100755 index 0000000..6676c6b --- /dev/null +++ b/scripts/parse-timing @@ -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 index 0000000..504c6a6 --- /dev/null +++ b/scripts/run.sh @@ -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}.* |