File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+
3
+ import re
4
+ from itertools import chain
5
+ from typing import Iterable , List
6
+
7
+ from analyze import Block
8
+
9
+ '''
10
+ Function-level stats (not Block, Logs, or Benchmark level)
11
+ '''
12
+
13
+ _RE_OCCUPANCY = re .compile (r'Final occupancy for function (?P<name>\S+):(?P<value>\d+)' )
14
+
15
+
16
+ def _occupancy_info_in_block_log (block : Block ) -> Iterable [int ]:
17
+ for m in _RE_OCCUPANCY .finditer (block .raw_log ):
18
+ yield m ['value' ]
19
+
20
+
21
+ def function_occupancy_info (logs : Iterable [Block ]) -> List [int ]:
22
+ return list (chain .from_iterable (map (_occupancy_info_in_block_log , logs )))
23
+
24
+
25
+ def avg_occupancy (logs : Iterable [Block ]) -> float :
26
+ occ_info = function_occupancy_info (logs )
27
+ return sum (occ_info ) / len (occ_info ) if occ_info else 0.0
You can’t perform that action at this time.
0 commit comments