1818import re
1919import subprocess
2020import os
21- import shutil
21+ import matplotlib . pyplot as plt
2222
2323
2424def read_from_file (file_name : str ):
@@ -31,7 +31,6 @@ def search_for_total_power(report_power: list[str]):
3131 match = re .match (r'Total\s+(([\w\.\-]+\s+)+)' , line )
3232 if match :
3333 total_power = match .group (2 ).replace (' ' , '' )
34- print (f'Total power: { total_power } Watts' )
3534 return float (total_power )
3635
3736 return 0
@@ -53,10 +52,27 @@ def search_for_total_power(report_power: list[str]):
5352files = os .listdir (args .input_dir )
5453files = sorted (files )
5554
55+ power_results = []
56+ clock_cycles_indices = []
57+
58+ current_clock_cycle = 0
5659for file in files :
57- print (file )
60+ clock_cycles_indices .append (current_clock_cycle )
61+ print (f'Processing clock cycle no. { current_clock_cycle } ' )
62+ current_clock_cycle += 1
63+
5864 os .symlink (args .input_dir + "/" + file , input_trace_file )
5965 subprocess .run ([open_sta_command , "-exit" , open_sta_script ], capture_output = True , text = True )
6066 report_contents = read_from_file (power_report_file )
6167 total_power = search_for_total_power (report_contents )
62- os .remove (input_trace_file )
68+ power_results .append (total_power )
69+ os .remove (input_trace_file )
70+
71+ plt .plot (clock_cycles_indices , power_results , marker = 'o' , linestyle = '-' , color = 'g' )
72+
73+ plt .title ("Power consumption over time" )
74+ plt .xlabel ("Clock cycles" )
75+ plt .ylabel ("Power consumption" )
76+ plt .grid (True )
77+
78+ plt .show ()
0 commit comments