diff options
| author | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-16 16:55:14 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-16 16:55:14 -0400 |
| commit | 6ea9939e0610a809f6f47d13ec68df00d1ca0afc (patch) | |
| tree | fe4a2eee3ddcf77e2367309dcd75a232b76dcd62 /dis/summarize.py | |
| parent | e9285d0cdea756a2830f0ace378e4197b36869aa (diff) | |
Move the DIS benchmarks up a directory and update hardcoded paths
Note that this repo does not attempt to keep a copy of the original
DIS benchmark distributions. UNC real-time has another repo for that.
Diffstat (limited to 'dis/summarize.py')
| -rwxr-xr-x | dis/summarize.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dis/summarize.py b/dis/summarize.py new file mode 100755 index 0000000..f8f6929 --- /dev/null +++ b/dis/summarize.py | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | #!/usr/bin/python3 | ||
| 2 | import sys | ||
| 3 | |||
| 4 | f = sys.argv[1] | ||
| 5 | res = {} | ||
| 6 | mem_res = {} | ||
| 7 | memw_res = {} | ||
| 8 | samples = {} | ||
| 9 | max_res = {} | ||
| 10 | |||
| 11 | with open(f) as fp: | ||
| 12 | for line in fp: | ||
| 13 | s = line.split() | ||
| 14 | if s[0] not in res: | ||
| 15 | # print(s[0]) | ||
| 16 | res[s[0]] = list([int(s[5])])#)int(s[5]) | ||
| 17 | mem_res[s[0]] = int(s[8]) | ||
| 18 | memw_res[s[0]] = int(s[9]) | ||
| 19 | samples[s[0]] = int(s[4]) | ||
| 20 | max_res[s[0]] = int(s[5]) | ||
| 21 | else: | ||
| 22 | res[s[0]].append(int(s[5])) | ||
| 23 | mem_res[s[0]] += int(s[8]) | ||
| 24 | memw_res[s[0]] += int(s[9]) | ||
| 25 | max_res[s[0]] = max(int(s[5]), max_res[s[0]]) | ||
| 26 | ## {{{ http://code.activestate.com/recipes/511478/ (r1) | ||
| 27 | import math | ||
| 28 | import functools | ||
| 29 | |||
| 30 | def percentile(N, percent, key=lambda x:x): | ||
| 31 | """ | ||
| 32 | Find the percentile of a list of values. | ||
| 33 | |||
| 34 | @parameter N - is a list of values. Note N MUST BE already sorted. | ||
| 35 | @parameter percent - a float value from 0.0 to 1.0. | ||
| 36 | @parameter key - optional key function to compute value from each element of N. | ||
| 37 | |||
| 38 | @return - the percentile of the values | ||
| 39 | """ | ||
| 40 | if not N: | ||
| 41 | return None | ||
| 42 | k = (len(N)-1) * percent | ||
| 43 | f = math.floor(k) | ||
| 44 | c = math.ceil(k) | ||
| 45 | if f == c: | ||
| 46 | return key(N[int(k)]) | ||
| 47 | d0 = key(N[int(f)]) * (c-k) | ||
| 48 | d1 = key(N[int(c)]) * (k-f) | ||
| 49 | return d0+d1 | ||
| 50 | ## end of http://code.activestate.com/recipes/511478/ }}} | ||
| 51 | """ | ||
| 52 | print("Average times:") | ||
| 53 | for r in res.keys(): | ||
| 54 | print(res[r]/samples[r]) | ||
| 55 | |||
| 56 | print("Average memory read:") | ||
| 57 | for r in mem_res.keys(): | ||
| 58 | print(mem_res[r]/samples[r]) | ||
| 59 | |||
| 60 | print("Average memory write:") | ||
| 61 | for r in memw_res.keys(): | ||
| 62 | print(memw_res[r]/samples[r]) | ||
| 63 | |||
| 64 | print("Max times:") | ||
| 65 | for r in max_res.keys(): | ||
| 66 | print(max_res[r]) | ||
| 67 | """ | ||
| 68 | print("Name\t\tAverage\t\tMax\t\t99th %\t\tAvg Mem Read\tAvg Mem Write\t") | ||
| 69 | for r in res.keys(): | ||
| 70 | # print(r + "\t\t" + str(res[r]/samples[r]) + "\t\t" + str(max_res[r])) | ||
| 71 | print("{:12}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}".format(r, sum(res[r])/len(res[r]), max(res[r]), percentile(sorted(res[r]), 0.99), mem_res[r]/samples[r], memw_res[r]/samples[r])) | ||
