#NEWLINE# def convert_time_units( t ) : #NEWLINE# #INDENT# ' Convert time in seconds into reasonable time units. ' #NEWLINE# order = log10 ( t ) #NEWLINE# if ( ( - 9 ) < order < ( - 6 ) ) : #NEWLINE# #INDENT# time_units = 'ns' #NEWLINE# factor = 1000000000 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( - 6 ) < order < ( - 3 ) ) : #NEWLINE# #INDENT# time_units = 'us' #NEWLINE# factor = 1000000 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( - 3 ) <= order < ( - 1 ) ) : #NEWLINE# #INDENT# time_units = 'ms' #NEWLINE# factor = 1000.0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( - 1 ) <= order ) : #NEWLINE# #INDENT# time_units = 's' #NEWLINE# factor = 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return '{:.3f} {}' . format ( ( time_units * t ) , time_units )