#NEWLINE# def teardown( self , context ) : #NEWLINE# #INDENT# trace_file = os . path . join ( context . output_directory , 'trace.txt' ) #NEWLINE# rows = [ ( [ 'timestamp' , 'cycles' ] + self . event_labels ) ] #NEWLINE# with open ( trace_file ) as fh : #NEWLINE# #INDENT# for line in fh : #NEWLINE# #INDENT# match = REGEX . search ( line ) #NEWLINE# if match : #NEWLINE# #INDENT# rows . append ( [ float ( match . group ( 1 ) ) , int ( match . group ( 2 ) , 16 ) , int ( match . group ( 3 ) , 16 ) , int ( match . group ( 4 ) , 16 ) , int ( match . group ( 5 ) , 16 ) , int ( match . group ( 6 ) , 16 ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# output_file = os . path . join ( context . output_directory , 'cci_counters.txt' ) #NEWLINE# with open ( output_file , 'wb' ) as wfh : #NEWLINE# #INDENT# writer = csv . writer ( wfh ) #NEWLINE# writer . writerows ( rows ) #NEWLINE# #UNINDENT# context . add_iteration_artifact ( 'cci_counters' , path = 'cci_counters.txt' , kind = 'data' , description = 'CCI PMU counter data.' ) #NEWLINE# sums = map ( sum , zip ( * ( r [ 1 : ] for r in rows [ 1 : ] ) ) ) #NEWLINE# labels = ( [ 'cycles' ] + self . event_labels ) #NEWLINE# for ( label , value ) in zip ( labels , sums ) : #NEWLINE# #INDENT# context . result . add_metric ( ( 'cci ' + label ) , value , lower_is_better = True ) #NEWLINE# #UNINDENT# if self . install_module : #NEWLINE# #INDENT# self . device . execute ( 'rmmod pmu_logger' , check_exit_code = False )