Show More
@@ -93,7 +93,7 b' python-profiler package from non-free.""")' | |||
|
93 | 93 | empty) statement in the first line. Cell mode allows you to easily |
|
94 | 94 | profile multiline blocks without having to put them in a separate |
|
95 | 95 | function. |
|
96 | ||
|
96 | ||
|
97 | 97 | The given statement (which doesn't require quote marks) is run via the |
|
98 | 98 | python profiler in a manner similar to the profile.run() function. |
|
99 | 99 | Namespaces are internally managed to work correctly; profile.run |
@@ -555,7 +555,7 b' python-profiler package from non-free.""")' | |||
|
555 | 555 | bdb.Breakpoint.bpbynumber = [None] |
|
556 | 556 | # Set an initial breakpoint to stop execution |
|
557 | 557 | maxtries = 10 |
|
558 | bp_file, bp_line = parse_breakpoint(opts.get('b', [1])[0], filename) | |
|
558 | bp_file, bp_line = parse_breakpoint(opts.get('b', ['1'])[0], filename) | |
|
559 | 559 | checkline = deb.checkline(bp_file, bp_line) |
|
560 | 560 | if not checkline: |
|
561 | 561 | for bp in range(bp_line + 1, bp_line + maxtries + 1): |
@@ -790,7 +790,7 b' python-profiler package from non-free.""")' | |||
|
790 | 790 | # but is there a better way to achieve that the code stmt has access |
|
791 | 791 | # to the shell namespace? |
|
792 | 792 | transform = self.shell.input_splitter.transform_cell |
|
793 | ||
|
793 | ||
|
794 | 794 | if cell is None: |
|
795 | 795 | # called as line magic |
|
796 | 796 | ast_setup = ast.parse("pass") |
@@ -798,10 +798,10 b' python-profiler package from non-free.""")' | |||
|
798 | 798 | else: |
|
799 | 799 | ast_setup = ast.parse(transform(stmt)) |
|
800 | 800 | ast_stmt = ast.parse(transform(cell)) |
|
801 | ||
|
801 | ||
|
802 | 802 | ast_setup = self.shell.transform_ast(ast_setup) |
|
803 | 803 | ast_stmt = self.shell.transform_ast(ast_stmt) |
|
804 | ||
|
804 | ||
|
805 | 805 | # This codestring is taken from timeit.template - we fill it in as an |
|
806 | 806 | # AST, so that we can apply our AST transformations to the user code |
|
807 | 807 | # without affecting the timing code. |
@@ -812,7 +812,7 b' python-profiler package from non-free.""")' | |||
|
812 | 812 | ' stmt\n' |
|
813 | 813 | ' _t1 = _timer()\n' |
|
814 | 814 | ' return _t1 - _t0\n') |
|
815 | ||
|
815 | ||
|
816 | 816 | class TimeitTemplateFiller(ast.NodeTransformer): |
|
817 | 817 | "This is quite tightly tied to the template definition above." |
|
818 | 818 | def visit_FunctionDef(self, node): |
@@ -820,15 +820,15 b' python-profiler package from non-free.""")' | |||
|
820 | 820 | self.generic_visit(node) |
|
821 | 821 | if node.name == "inner": |
|
822 | 822 | node.body[:1] = ast_setup.body |
|
823 | ||
|
823 | ||
|
824 | 824 | return node |
|
825 | ||
|
825 | ||
|
826 | 826 | def visit_For(self, node): |
|
827 | 827 | "Fill in the statement to be timed" |
|
828 | 828 | if getattr(getattr(node.body[0], 'value', None), 'id', None) == 'stmt': |
|
829 | 829 | node.body = ast_stmt.body |
|
830 | 830 | return node |
|
831 | ||
|
831 | ||
|
832 | 832 | timeit_ast = TimeitTemplateFiller().visit(timeit_ast_template) |
|
833 | 833 | timeit_ast = ast.fix_missing_locations(timeit_ast) |
|
834 | 834 | |
@@ -921,14 +921,14 b' python-profiler package from non-free.""")' | |||
|
921 | 921 | # fail immediately if the given expression can't be compiled |
|
922 | 922 | |
|
923 | 923 | expr = self.shell.prefilter(parameter_s,False) |
|
924 | ||
|
924 | ||
|
925 | 925 | # Minimum time above which parse time will be reported |
|
926 | 926 | tp_min = 0.1 |
|
927 | ||
|
927 | ||
|
928 | 928 | t0 = clock() |
|
929 | 929 | expr_ast = ast.parse(expr) |
|
930 | 930 | tp = clock()-t0 |
|
931 | ||
|
931 | ||
|
932 | 932 | # Apply AST transformations |
|
933 | 933 | expr_ast = self.shell.transform_ast(expr_ast) |
|
934 | 934 | |
@@ -945,7 +945,7 b' python-profiler package from non-free.""")' | |||
|
945 | 945 | t0 = clock() |
|
946 | 946 | code = compile(expr_ast, source, mode) |
|
947 | 947 | tc = clock()-t0 |
|
948 | ||
|
948 | ||
|
949 | 949 | # skew measurement as little as possible |
|
950 | 950 | glob = self.shell.user_ns |
|
951 | 951 | wtime = time.time |
@@ -1053,17 +1053,17 b' python-profiler package from non-free.""")' | |||
|
1053 | 1053 | print 'Macro `%s` created. To execute, type its name (without quotes).' % name |
|
1054 | 1054 | print '=== Macro contents: ===' |
|
1055 | 1055 | print macro, |
|
1056 | ||
|
1056 | ||
|
1057 | 1057 | @magic_arguments.magic_arguments() |
|
1058 | 1058 | @magic_arguments.argument('output', type=str, default='', nargs='?', |
|
1059 | 1059 | help="""The name of the variable in which to store output. |
|
1060 | 1060 | This is a utils.io.CapturedIO object with stdout/err attributes |
|
1061 | 1061 | for the text of the captured output. |
|
1062 | ||
|
1062 | ||
|
1063 | 1063 | CapturedOutput also has a show() method for displaying the output, |
|
1064 | 1064 | and __call__ as well, so you can use that to quickly display the |
|
1065 | 1065 | output. |
|
1066 | ||
|
1066 | ||
|
1067 | 1067 | If unspecified, captured output is discarded. |
|
1068 | 1068 | """ |
|
1069 | 1069 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now