class_docstr: Class for timing execution speed of small code snippets.
  
  The constructor takes a statement to be timed, an additional
  statement used for setup, and a timer function.  Both statements
  default to 'pass'; the timer function is platform-dependent (see
  module doc string).  If 'globals' is specified, the code will be
  executed within that namespace (as opposed to inside timeit's
  namespace).
  
  To measure the execution time of the first statement, use the
  timeit() method.  The repeat() method is a convenience to call
  timeit() multiple times and return a list of results.
  
  The statements may contain newlines, as long as they don't contain
  multi-line string literals.
docstr: Helper to print a traceback from the timed code.
  
  Typical use:
  
      t = Timer(...)       # outside the try/except
      try:
          t.timeit(...)    # or t.repeat(...)
      except:
          t.print_exc()
  
  The advantage over the standard traceback is that source lines
  in the compiled template will be displayed.
  
  The optional file argument directs where the traceback is
  sent; it defaults to sys.stderr.
docstr_tok: ["Helper","to","print","a","traceback","from","the","timed","code",".","Typical","use",":","t","=","Timer","(","...",")","#","outside","the","try\/except","try",":","t.timeit","(","...",")","#","or","t.repeat","(","...",")","except",":","t.print_exc","(",")","The","advantage","over","the","standard","traceback","is","that","source","lines","in","the","compiled","template","will","be","displayed",".","The","optional","file","argument","directs","where","the","traceback","is","sent",";","it","defaults","to","sys.stderr","."]
code: def print_exc(self, file=None):
      """Helper to print a traceback from the timed code.
  
      Typical use:
  
          t = Timer(...)       # outside the try/except
          try:
              t.timeit(...)    # or t.repeat(...)
          except:
              t.print_exc()
  
      The advantage over the standard traceback is that source lines
      in the compiled template will be displayed.
  
      The optional file argument directs where the traceback is
      sent; it defaults to sys.stderr.
      """
      import linecache, traceback
  
      if self.src is not None:
          linecache.cache[dummy_src_name] = (
              len(self.src),
              None,
              self.src.split("\n"),
              dummy_src_name,
          )
      # else the source is already stored somewhere else
  
      traceback.print_exc(file=file)
  
file_path: cpython/Lib/timeit.py
imports: import gc
  import itertools
  import sys
  import time
label_desc: Use image node_id 2 for calling the Timer obj's underlying member method code with example usage: obj.print_exc(file) without return types