##// END OF EJS Templates
Add ExecutionMagics._run_with_profiler
Takafumi Arakaki -
Show More
@@ -77,8 +77,7 b' python-profiler package from non-free.""")'
77
77
78 @skip_doctest
78 @skip_doctest
79 @line_cell_magic
79 @line_cell_magic
80 def prun(self, parameter_s='', cell=None, user_mode=True,
80 def prun(self, parameter_s='', cell=None):
81 opts=None,arg_lst=None,prog_ns=None, namespace=None):
82
81
83 """Run a statement through the python code profiler.
82 """Run a statement through the python code profiler.
84
83
@@ -178,6 +177,11 b' python-profiler package from non-free.""")'
178
177
179 In [1]: import profile; profile.help()
178 In [1]: import profile; profile.help()
180 """
179 """
180 return self._run_with_profiler(parameter_s, cell)
181
182 def _run_with_profiler(
183 self, parameter_s='', cell=None, user_mode=True,
184 opts=None, arg_lst=None, prog_ns=None, namespace=None):
181
185
182 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
186 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
183
187
@@ -563,7 +567,9 b' python-profiler package from non-free.""")'
563 stats = None
567 stats = None
564 with self.shell.readline_no_record:
568 with self.shell.readline_no_record:
565 if 'p' in opts:
569 if 'p' in opts:
566 stats = self.prun('', code, False, opts, namespace=code_ns)
570 stats = self._run_with_profiler(
571 cell=code, user_mode=False, opts=opts,
572 namespace=code_ns)
567 else:
573 else:
568 if 'd' in opts:
574 if 'd' in opts:
569 self._run_with_debugger(
575 self._run_with_debugger(
General Comments 0
You need to be logged in to leave comments. Login now