From: Lucas De Marchi Date: Tue, 13 Aug 2013 18:39:03 +0000 (-0300) Subject: scripts: Add scripts to parse hashfunc timings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68882b4861e182bcfe7af092ba2f6d822c611968;p=thirdparty%2Fkmod.git scripts: Add scripts to parse hashfunc timings --- diff --git a/scripts/parse-timing b/scripts/parse-timing new file mode 100755 index 00000000..6676c6bb --- /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 00000000..504c6a65 --- /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}.*