def _timeitlike_time_format(time_seconds, precision=3):
 usec = (time_seconds * 1000000.0)
 if (usec < 1000):
  return ('%.*g usec' % (precision, usec))
 else:
  msec = (usec / 1000)
  if (msec < 1000):
   return ('%.*g msec' % (precision, msec))
  else:
   sec = (msec / 1000)
   return ('%.*g sec' % (precision, sec))

def _timeitlike_time_format ( time_seconds , precision = 3 ) : usec = ( time_seconds * 1000000.0 ) if ( usec < 1000 ) : return ( '%.*g usec' % ( precision , usec ) ) else : msec = ( usec / 1000 ) if ( msec < 1000 ) : return ( '%.*g msec' % ( precision , msec ) ) else : sec = ( msec / 1000 ) return ( '%.*g sec' % ( precision , sec ) )
shamelessly adapted formatting from timeit .