def print_result_from_timeit(stmt='pass', setup='pass', number=1000000):
 units = ['s', 'ms', 'us', 'ns']
 duration = timeit(stmt, setup, number=number)
 avg_duration = (duration / float(number))
 thousands = int(math.floor(math.log(avg_duration, 1000)))
 print ('Total time: %fs. Average run: %.3f%s.' % (duration, (avg_duration * (1000 ** (- thousands))), units[(- thousands)]))

def print_result_from_timeit ( stmt = 'pass' , setup = 'pass' , number = 1000000 ) : units = [ 's' , 'ms' , 'us' , 'ns' ] duration = timeit ( stmt , setup , number = number ) avg_duration = ( duration / float ( number ) ) thousands = int ( math . floor ( math . log ( avg_duration , 1000 ) ) ) print ( 'Total time: %fs. Average run: %.3f%s.' % ( duration , ( avg_duration * ( 1000 ** ( - thousands ) ) ) , units [ ( - thousands ) ] ) )
clean function to know how much time took the execution of one statement .