-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.py
More file actions
64 lines (49 loc) · 1.81 KB
/
Copy pathstats.py
File metadata and controls
64 lines (49 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import itertools
import os
import matplotlib.pyplot as plt
import numpy as np
import common
import run
def denoised_average(a: np.typing.NDArray) -> float:
half_size = a.shape[0] // 2
return float(np.average(np.sort(a)[:half_size]))
def events_statistics(results: list[run.RunResult]) -> dict[str, dict[str, float]]:
"""
Returns a dictionary where keys are the events measured in results, and
values are a dictionary of average value by strategy. The values in this
dictionary are normalized by the average values of all stategies for the
same event
"""
if len(results) == 0:
return {}
statistics = {}
events = results[0].events.keys()
for event in events:
event_statistics = {
res.run.strategy: denoised_average(res.events[event])
for res in results
}
average = float(np.average(list(event_statistics.values())))
if average != 0:
for key, value in event_statistics.items():
event_statistics[key] = value / average
statistics[event] = event_statistics
return statistics
def dsp_compiler_arch(result: run.RunResult):
run = result.run
return (
os.path.join(run.directory, f'{run.program_name}.dsp'),
result.run.compiler,
result.run.arch
)
def show_statistics(results: list[run.RunResult]):
if len(results) == 0:
return
statistics = [events_statistics(list(group))
for _, group in itertools.groupby(results, dsp_compiler_arch)]
for strategy in common.strategies:
print(f'\033[1mPerformance of strategy {strategy}:\033[0m')
for event in results[0].events.keys():
perf = np.average([s[event][strategy] for s in statistics])
print(f'{event}: {perf}')
print()