1
1
#!/usr/bin/env python3
2
2
3
+ import argparse
3
4
import re
4
5
from itertools import chain
5
6
from typing import Iterable , List
6
7
7
- from analyze import Block
8
+ import analyze
9
+ from analyze import Block , ioutils , utils
8
10
9
11
'''
10
12
Function-level stats (not Block, Logs, or Benchmark level)
@@ -25,3 +27,27 @@ def function_occupancy_info(logs: Iterable[Block]) -> List[int]:
25
27
def avg_occupancy (logs : Iterable [Block ]) -> float :
26
28
occ_info = function_occupancy_info (logs )
27
29
return sum (occ_info ) / len (occ_info ) if occ_info else 0.0
30
+
31
+
32
+ def raw_main (argv : List [str ] = []):
33
+ parser = argparse .ArgumentParser (
34
+ description = 'Computes the block stats for the logs' )
35
+ parser .add_argument ('--stat' , choices = ('occ' ,),
36
+ help = 'Which stat to compute' )
37
+ parser .add_argument ('logs' , help = 'The logs to analyze' )
38
+ ioutils .add_output_format_arg (parser )
39
+ args = analyze .parse_args (parser , 'logs' )
40
+
41
+ STATS = {
42
+ 'occ' : ('Average Occupancy' , avg_occupancy ),
43
+ }
44
+ label , f = STATS [args .stat ]
45
+
46
+ results = utils .foreach_bench (lambda bench : {label : f (bench )}, args .logs )
47
+
48
+ args .format (results )
49
+
50
+
51
+ if __name__ == '__main__' :
52
+ import sys
53
+ raw_main (sys .argv )
0 commit comments