File tree 1 file changed +36
-0
lines changed
src/tests/integration/test-data/show
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env python3
2
+
3
+ # input: path to a kcfg file
4
+ # output: cse steps
5
+
6
+ import re
7
+ import sys
8
+
9
+ if __name__ == "__main__" :
10
+ kcfg_path = sys .argv [1 ]
11
+
12
+ with open (kcfg_path , "r" ) as f :
13
+ prev_node_id = None
14
+ curr_node_id = None
15
+ is_calling = False
16
+ is_callee = False
17
+ counter = 0
18
+ for line in f :
19
+ # after the ┌─, ├─, └─ is the node id
20
+ for match in re .finditer (r"[┌└├]─ (\d+)" , line ):
21
+ prev_node_id = curr_node_id
22
+ curr_node_id = match .group (1 )
23
+ if is_callee :
24
+ print (f'{ prev_node_id } -> { curr_node_id } ' )
25
+ is_callee = False
26
+ counter += 1
27
+ # if the line has "k: #execute ~> #return", then it tries to call a function
28
+ if "k: #execute ~> #return" in line :
29
+ is_calling = True
30
+ # if is_calling and the line has "(\d+ step)"
31
+ if is_calling and re .search (r"\d+ step" , line ):
32
+ is_calling = False
33
+ steps = int (re .search (r"(\d+) step" , line ).group (1 ))
34
+ if steps == 1 :
35
+ is_callee = True
36
+ print (f"Total CSE Steps: { counter } " )
You can’t perform that action at this time.
0 commit comments