#NEWLINE# def update_result( self , context ) : #NEWLINE# #INDENT# super ( GlbCorp , self ) . update_result ( context ) #NEWLINE# self . monitor . stop ( ) #NEWLINE# iteration = 0 #NEWLINE# results = [ ] #NEWLINE# with open ( self . logcat_log ) as fh : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# line = fh . next ( ) #NEWLINE# result_lines = [ ] #NEWLINE# while True : #NEWLINE# #INDENT# if OLD_RESULT_START_REGEX . search ( line ) : #NEWLINE# #INDENT# self . preamble_regex = OLD_PREAMBLE_REGEX #NEWLINE# self . result_start_regex = OLD_RESULT_START_REGEX #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if NEW_RESULT_START_REGEX . search ( line ) : #NEWLINE# #INDENT# self . preamble_regex = NEW_PREAMBLE_REGEX #NEWLINE# self . result_start_regex = NEW_RESULT_START_REGEX #NEWLINE# #UNINDENT# #UNINDENT# if ( self . result_start_regex and self . result_start_regex . search ( line ) ) : #NEWLINE# #INDENT# result_lines . append ( '{' ) #NEWLINE# line = fh . next ( ) #NEWLINE# while self . preamble_regex . search ( line ) : #NEWLINE# #INDENT# result_lines . append ( self . preamble_regex . sub ( '' , line ) ) #NEWLINE# line = fh . next ( ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# result = json . loads ( '' . join ( result_lines ) ) #NEWLINE# results . append ( result ) #NEWLINE# if iteration : #NEWLINE# #INDENT# suffix = '_{}' . format ( iteration ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# suffix = '' #NEWLINE# #UNINDENT# for sub_result in result [ 'results' ] : #NEWLINE# #INDENT# frames = sub_result [ 'score' ] #NEWLINE# elapsed_time = ( sub_result [ 'elapsed_time' ] / 1000 ) #NEWLINE# fps = ( frames / elapsed_time ) #NEWLINE# context . result . add_metric ( ( 'score' + suffix ) , frames , 'frames' ) #NEWLINE# context . result . add_metric ( ( 'fps' + suffix ) , fps ) #NEWLINE# #UNINDENT# #UNINDENT# except ValueError : #NEWLINE# #INDENT# self . logger . warning ( 'Could not parse result for iteration {}' . format ( iteration ) ) #NEWLINE# #UNINDENT# result_lines = [ ] #NEWLINE# iteration += 1 #NEWLINE# #UNINDENT# line = fh . next ( ) #NEWLINE# #UNINDENT# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# if results : #NEWLINE# #INDENT# outfile = os . path . join ( context . output_directory , 'glb-results.json' ) #NEWLINE# with open ( outfile , 'wb' ) as wfh : #NEWLINE# #INDENT# json . dump ( results , wfh , indent = 4 )