class_docstr: Magics related to code execution, debugging, profiling, etc.
  
      
docstr: Time execution of a Python statement or expression.
  
  The CPU and wall clock times are printed, and the value of the
  expression (if any) is returned.  Note that under Win32, system time
  is always reported as 0, since it can not be measured.
  
  This function can be used both as a line and cell magic:
  
  - In line mode you can time a single-line statement (though multiple
    ones can be chained with using semicolons).
  
  - In cell mode, you can time the cell body (a directly 
    following statement raises an error).
  
  This function provides very basic timing functionality.  Use the timeit 
  magic for more control over the measurement.
  
  Examples
  --------
  ::
  
    In [1]: %time 2**128
    CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
    Wall time: 0.00
    Out[1]: 340282366920938463463374607431768211456L
  
    In [2]: n = 1000000
  
    In [3]: %time sum(range(n))
    CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
    Wall time: 1.37
    Out[3]: 499999500000L
  
    In [4]: %time print 'hello world'
    hello world
    CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
    Wall time: 0.00
  
    Note that the time needed by Python to compile the given expression
    will be reported if it is more than 0.1s.  In this example, the
    actual exponentiation is done by Python at compilation time, so while
    the expression can take a noticeable amount of time to compute, that
    time is purely due to the compilation:
  
    In [5]: %time 3**9999;
    CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
    Wall time: 0.00 s
  
    In [6]: %time 3**999999;
    CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
    Wall time: 0.00 s
    Compiler : 0.78 s
    
docstr_tok: ["Time","execution","of","a","Python","statement","or","expression",".","The","CPU","and","wall","clock","times","are","printed",",","and","the","value","of","the","expression","(","if","any",")","is","returned",".","Note","that","under","Win32",",","system","time","is","always","reported","as","0",",","since","it","can","not","be","measured",".","This","function","can","be","used","both","as","a","line","and","cell","magic",":","-","In","line","mode","you","can","time","a","single-line","statement","(","though","multiple","ones","can","be","chained","with","using","semicolons",")",".","-","In","cell","mode",",","you","can","time","the","cell","body","(","a","directly","following","statement","raises","an","error",")",".","This","function","provides","very","basic","timing","functionality",".","Use","the","timeit","magic","for","more","control","over","the","measurement",".","Examples","--","--","--","--",":",":","In","[","1","]",":","%","time","2","*","*","128","CPU","times",":","user","0.00","s",",","sys",":","0.00","s",",","total",":","0.00","s","Wall","time",":","0.00","Out","[","1","]",":","340282366920938463463374607431768211456L","In","[","2","]",":","n","=","1000000","In","[","3","]",":","%","time","sum","(","range","(","n",")",")","CPU","times",":","user","1.20","s",",","sys",":","0.05","s",",","total",":","1.25","s","Wall","time",":","1.37","Out","[","3","]",":","499999500000L","In","[","4","]",":","%","time","print","'hello","world'","hello","world","CPU","times",":","user","0.00","s",",","sys",":","0.00","s",",","total",":","0.00","s","Wall","time",":","0.00","Note","that","the","time","needed","by","Python","to","compile","the","given","expression","will","be","reported","if","it","is","more","than","0.1s",".","In","this","example",",","the","actual","exponentiation","is","done","by","Python","at","compilation","time",",","so","while","the","expression","can","take","a","noticeable","amount","of","time","to","compute",",","that","time","is","purely","due","to","the","compilation",":","In","[","5","]",":","%","time","3","*","*","9999",";","CPU","times",":","user","0.00","s",",","sys",":","0.00","s",",","total",":","0.00","s","Wall","time",":","0.00","s","In","[","6","]",":","%","time","3","*","*","999999",";","CPU","times",":","user","0.00","s",",","sys",":","0.00","s",",","total",":","0.00","s","Wall","time",":","0.00","s","Compiler",":","0.78","s"]
code: def time(self, line="", cell=None, local_ns=None):
      """Time execution of a Python statement or expression.
  
      The CPU and wall clock times are printed, and the value of the
      expression (if any) is returned.  Note that under Win32, system time
      is always reported as 0, since it can not be measured.
  
      This function can be used both as a line and cell magic:
  
      - In line mode you can time a single-line statement (though multiple
        ones can be chained with using semicolons).
  
      - In cell mode, you can time the cell body (a directly
        following statement raises an error).
  
      This function provides very basic timing functionality.  Use the timeit
      magic for more control over the measurement.
  
      Examples
      --------
      ::
  
        In [1]: %time 2**128
        CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
        Wall time: 0.00
        Out[1]: 340282366920938463463374607431768211456L
  
        In [2]: n = 1000000
  
        In [3]: %time sum(range(n))
        CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
        Wall time: 1.37
        Out[3]: 499999500000L
  
        In [4]: %time print 'hello world'
        hello world
        CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
        Wall time: 0.00
  
        Note that the time needed by Python to compile the given expression
        will be reported if it is more than 0.1s.  In this example, the
        actual exponentiation is done by Python at compilation time, so while
        the expression can take a noticeable amount of time to compute, that
        time is purely due to the compilation:
  
        In [5]: %time 3**9999;
        CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
        Wall time: 0.00 s
  
        In [6]: %time 3**999999;
        CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
        Wall time: 0.00 s
        Compiler : 0.78 s
      """
  
      # fail immediately if the given expression can't be compiled
  
      if line and cell:
          raise UsageError(
              "Can't use statement directly after '%%time'!"
          )
  
      if cell:
          expr = self.shell.input_transformer_manager.transform_cell(
              cell
          )
      else:
          expr = self.shell.input_transformer_manager.transform_cell(
              line
          )
  
      # Minimum time above which parse time will be reported
      tp_min = 0.1
  
      t0 = clock()
      expr_ast = self.shell.compile.ast_parse(expr)
      tp = clock() - t0
  
      # Apply AST transformations
      expr_ast = self.shell.transform_ast(expr_ast)
  
      # Minimum time above which compilation time will be reported
      tc_min = 0.1
  
      if len(expr_ast.body) == 1 and isinstance(
          expr_ast.body[0], ast.Expr
      ):
          mode = "eval"
          source = "<timed eval>"
          expr_ast = ast.Expression(expr_ast.body[0].value)
      else:
          mode = "exec"
          source = "<timed exec>"
      t0 = clock()
      code = self.shell.compile(expr_ast, source, mode)
      tc = clock() - t0
  
      # skew measurement as little as possible
      glob = self.shell.user_ns
      wtime = time.time
      # time execution
      wall_st = wtime()
      if mode == "eval":
          st = clock2()
          out = eval(code, glob, local_ns)
          end = clock2()
      else:
          st = clock2()
          exec(code, glob, local_ns)
          end = clock2()
          out = None
      wall_end = wtime()
      # Compute actual times and report
      wall_time = wall_end - wall_st
      cpu_user = end[0] - st[0]
      cpu_sys = end[1] - st[1]
      cpu_tot = cpu_user + cpu_sys
      # On windows cpu_sys is always zero, so no new information to the next print
      if sys.platform != "win32":
          print(
              "CPU times: user %s, sys: %s, total: %s"
              % (
                  _format_time(cpu_user),
                  _format_time(cpu_sys),
                  _format_time(cpu_tot),
              )
          )
      print("Wall time: %s" % _format_time(wall_time))
      if tc > tc_min:
          print("Compiler : %s" % _format_time(tc))
      if tp > tp_min:
          print("Parser   : %s" % _format_time(tp))
      return out
  
imports: from __future__ import print_function
  from __future__ import absolute_import
  import ast
  import bdb
  import gc
  import itertools
  import os
  import sys
  import time
  import timeit
  from pdb import Restart
  from IPython.core import oinspect
  from IPython.core import magic_arguments
  from IPython.core import page
  from IPython.core.error import UsageError
  from IPython.core.macro import Macro
  from IPython.core.magic import Magics, magics_class, line_magic, cell_magic, line_cell_magic, on_off, needs_local_scope
  from IPython.testing.skipdoctest import skip_doctest
  from IPython.utils import py3compat
  from IPython.utils.py3compat import builtin_mod, iteritems, PY3
  from IPython.utils.contexts import preserve_keys
  from IPython.utils.capture import capture_output
  from IPython.utils.ipstruct import Struct
  from IPython.utils.module_paths import find_mod
  from IPython.utils.path import get_py_filename, shellglob
  from IPython.utils.timing import clock, clock2
  from warnings import warn
  from logging import error
label_desc: Use image node_id 14 for calling the ExecutionMagics obj's underlying member method code with example usage: obj.time(line, cell, local_ns) and returns: out