Exemplo n.º 1
0
def format_cpu_times(show_micro_seconds_per_tick=True):
  t = os.times()
  result = "u+s,u,s: %.2f %.2f %.2f" % (t[0] + t[1], t[0], t[1])
  if (show_micro_seconds_per_tick):
    try: python_ticker = sys.gettickeraccumulation()
    except AttributeError: pass
    else:
      result += " micro-seconds/tick: %.3f" % ((t[0]+t[1])/python_ticker*1.e6)
  return result
Exemplo n.º 2
0
def show_total_time(
      out=None,
      show_micro_seconds_per_bytecode_instruction=True):
  if (out == None): out = sys.stdout
  total_time = user_plus_sys_time().get()
  try: python_ticker = sys.gettickeraccumulation()
  except AttributeError: pass
  else:
    print >> out, "Time per interpreted Python bytecode instruction:",
    print >> out, "%.3f micro seconds" % (total_time / python_ticker * 1.e6)
  print >> out, "Total CPU time: %.2f %s" % human_readable_time(total_time)
Exemplo n.º 3
0
def format_cpu_times(show_micro_seconds_per_tick=True):
    t = os.times()
    result = "u+s,u,s: %.2f %.2f %.2f" % (t[0] + t[1], t[0], t[1])
    if (show_micro_seconds_per_tick):
        try:
            python_ticker = sys.gettickeraccumulation()
        except AttributeError:
            pass
        else:
            result += " micro-seconds/tick: %.3f" % (
                (t[0] + t[1]) / python_ticker * 1.e6)
    return result
Exemplo n.º 4
0
def show_total_time(out=None,
                    show_micro_seconds_per_bytecode_instruction=True):
    if (out == None): out = sys.stdout
    total_time = user_plus_sys_time().get()
    try:
        python_ticker = sys.gettickeraccumulation()
    except AttributeError:
        pass
    else:
        print >> out, "Time per interpreted Python bytecode instruction:",
        print >> out, "%.3f micro seconds" % (total_time / python_ticker *
                                              1.e6)
    print >> out, "Total CPU time: %.2f %s" % human_readable_time(total_time)
Exemplo n.º 5
0
 def __call__(self):
   out = self.out
   if (out is None): out = sys.stdout
   t = os.times()
   usr_plus_sys = t[0] + t[1]
   try: ticks = sys.gettickeraccumulation()
   except AttributeError: ticks = None
   s = "usr+sys time: %.2f seconds" % usr_plus_sys
   if (ticks is not None):
     s += ", ticks: %d" % ticks
     if (ticks != 0):
       s += ", micro-seconds/tick: %.3f" % (usr_plus_sys*1.e6/ticks)
   print >> out, s
   show_wall_clock_time(seconds=time.time()-self.time_start, out=out)
Exemplo n.º 6
0
 def __call__(self):
     out = self.out
     if (out is None): out = sys.stdout
     t = os.times()
     usr_plus_sys = t[0] + t[1]
     try:
         ticks = sys.gettickeraccumulation()
     except AttributeError:
         ticks = None
     s = "usr+sys time: %.2f seconds" % usr_plus_sys
     if (ticks is not None):
         s += ", ticks: %d" % ticks
         if (ticks != 0):
             s += ", micro-seconds/tick: %.3f" % (usr_plus_sys * 1.e6 /
                                                  ticks)
     print >> out, s
     show_wall_clock_time(seconds=time.time() - self.time_start, out=out)
Exemplo n.º 7
0
 def __init__(self, worker, n, n_terms):
   time_0 = usr_and_sys()
   ticks_0 = sys.gettickeraccumulation()
   self.result = worker(n, n_terms)
   self.ticks_diff = sys.gettickeraccumulation() - ticks_0
   self.time_diff = usr_and_sys() - time_0
Exemplo n.º 8
0
 def __init__(self, worker, n, n_terms):
     time_0 = usr_and_sys()
     ticks_0 = sys.gettickeraccumulation()
     self.result = worker(n, n_terms)
     self.ticks_diff = sys.gettickeraccumulation() - ticks_0
     self.time_diff = usr_and_sys() - time_0