Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add ExecutionMagics._run_with_profiler

  • Loading branch information...
commit 6fbcf5c175e555aa845394f4ac280e847e3f6c84 1 parent 8418a7f
@tkf authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 IPython/core/magics/execution.py
View
12 IPython/core/magics/execution.py
@@ -77,8 +77,7 @@ def profile_missing_notice(self, *args, **kwargs):
@skip_doctest
@line_cell_magic
- def prun(self, parameter_s='', cell=None, user_mode=True,
- opts=None,arg_lst=None,prog_ns=None, namespace=None):
+ def prun(self, parameter_s='', cell=None):
"""Run a statement through the python code profiler.
@@ -178,6 +177,11 @@ def prun(self, parameter_s='', cell=None, user_mode=True,
In [1]: import profile; profile.help()
"""
+ return self._run_with_profiler(parameter_s, cell)
+
+ def _run_with_profiler(
+ self, parameter_s='', cell=None, user_mode=True,
+ opts=None, arg_lst=None, prog_ns=None, namespace=None):
opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
@@ -563,7 +567,9 @@ def run(self, parameter_s='', runner=None,
stats = None
with self.shell.readline_no_record:
if 'p' in opts:
- stats = self.prun('', code, False, opts, namespace=code_ns)
+ stats = self._run_with_profiler(
+ cell=code, user_mode=False, opts=opts,
+ namespace=code_ns)
else:
if 'd' in opts:
self._run_with_debugger(
Please sign in to comment.
Something went wrong with that request. Please try again.