#NEWLINE# def on_profile( self , frame , event , arg ) : #NEWLINE# #INDENT# timestamp = high_res_time ( ) #NEWLINE# if ( ( event == 'call' ) or ( event == 'c_call' ) ) : #NEWLINE# #INDENT# event_id = CALL_EVENT #NEWLINE# if ( event == 'call' ) : #NEWLINE# #INDENT# target = frame . f_code . co_name #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( event == 'c_call' ) : #NEWLINE# #INDENT# target = arg . __name__ #NEWLINE# #UNINDENT# #UNINDENT# content = ( struct . pack ( '=dL' , timestamp , len ( target ) ) + target ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( event == 'return' ) or ( event == 'c_return' ) or ( event == 'c_exception' ) ) : #NEWLINE# #INDENT# event_id = RETURN_EVENT #NEWLINE# content = struct . pack ( '=d' , timestamp ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( event == 'exception' ) or ( event == 'c_exception' ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . logger . warning ( ( '[profile] Unknown event: %s' % event ) ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( ( self . _current_profile_mmap . tell ( ) + len ( content ) ) + 2 ) > len ( self . _current_profile_mmap ) ) : #NEWLINE# #INDENT# self . _new_mmap ( ) #NEWLINE# #UNINDENT# self . _current_profile_mmap . write_byte ( chr ( PROFILE_IDENTIFIER ) ) #NEWLINE# self . _current_profile_mmap . write_byte ( chr ( event_id ) ) #NEWLINE# self . _current_profile_mmap . write ( content )