forked from RogerQi/SPIMBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcycle_analyzer.py
More file actions
26 lines (23 loc) · 880 Bytes
/
Copy pathcycle_analyzer.py
File metadata and controls
26 lines (23 loc) · 880 Bytes
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
from __future__ import print_function
import sys
feature = "spimbot.s:"
def main(start_line_num, end_line_num):
with open("profile.txt") as f:
a = f.readlines()
total_cycles = 0
for line in a:
ind = line.find(feature)
if ind == -1:
continue
slice_start_ind = ind + len(feature)
slice_end_ind = line[slice_start_ind:].find(":") + slice_start_ind
current_mips_line = int(line[slice_start_ind:slice_end_ind])
if current_mips_line >= start_line_num and current_mips_line <= end_line_num:
cnt = int(line[:line.find("[")].replace(" ", ""))
if cnt == -1: cnt = 0
total_cycles += cnt
print("Total cycles between specified lines:", total_cycles)
if __name__ == '__main__':
start_num = int(sys.argv[1])
end_num = int(sys.argv[2])
main(start_num, end_num)