#NEWLINE# def show( stats ) : #NEWLINE# #INDENT# p = stats . top_profile ( ) #NEWLINE# if ( not p ) : #NEWLINE# #INDENT# print ( 'no stats' ) #NEWLINE# return #NEWLINE# #UNINDENT# p . sort ( key = ( lambda x : x [ 1 ] ) , reverse = True ) #NEWLINE# top = p [ 0 ] [ 1 ] #NEWLINE# max_len = max ( [ _namelen ( e [ 0 ] ) for e in p ] ) #NEWLINE# print ( ' vmprof output:' ) #NEWLINE# print ( ( ( ' %:      name:' + ( ' ' * ( max_len - 3 ) ) ) + 'location:' ) ) #NEWLINE# for ( k , v ) in p : #NEWLINE# #INDENT# v = ( '%.1f%%' % ( ( float ( v ) / top ) * 100 ) ) #NEWLINE# if ( v == '0.0%' ) : #NEWLINE# #INDENT# v = '<0.1%' #NEWLINE# #UNINDENT# if k . startswith ( 'py:' ) : #NEWLINE# #INDENT# ( _ , func_name , lineno , filename ) = k . split ( ':' , 3 ) #NEWLINE# lineno = int ( lineno ) #NEWLINE# print ( ( ' %s %s %s:%d' % ( v . ljust ( 7 ) , func_name . ljust ( ( max_len + 1 ) ) , filename , lineno ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( ( ' %s %s' % ( v . ljust ( 7 ) , k . ljust ( ( max_len + 1 ) ) ) ) )