def timetrace(message, idstring, tracemessage='TEST_MESSAGE', final=False):
 if message.startswith(tracemessage):
  try:
   (prefix, tlast, t0) = message.split(None, 2)
   (tlast, t0) = (float(tlast), float(t0))
  except (IndexError, ValueError):
   t0 = time()
   tlast = t0
   t1 = t0
  else:
   t1 = time()
  print(('** timetrace (%s): dT=%fs, total=%fs.' % (idstring, (t1 - tlast), (t1 - t0))))
  if final:
   message = (' ****  %s (total %f) **** ' % (tracemessage, (t1 - t0)))
  else:
   message = ('%s %f %f' % (tracemessage, t1, t0))
 return message

def timetrace ( message , idstring , tracemessage = 'TEST_MESSAGE' , final = False ) : if message . startswith ( tracemessage ) : try : ( prefix , tlast , t0 ) = message . split ( None , 2 ) ( tlast , t0 ) = ( float ( tlast ) , float ( t0 ) ) except ( IndexError , ValueError ) : t0 = time ( ) tlast = t0 t1 = t0 else : t1 = time ( ) print ( ( '** timetrace (%s): dT=%fs, total=%fs.' % ( idstring , ( t1 - tlast ) , ( t1 - t0 ) ) ) ) if final : message = ( ' ****  %s (total %f) **** ' % ( tracemessage , ( t1 - t0 ) ) ) else : message = ( '%s %f %f' % ( tracemessage , t1 , t0 ) ) return message
trace a message with time stamps .