##// END OF EJS Templates
Use shell futures environment for code in %time and %timeit...
Thomas Kluyver -
Show More
@@ -971,11 +971,11 b' python-profiler package from non-free.""")'
971
971
972 if cell is None:
972 if cell is None:
973 # called as line magic
973 # called as line magic
974 ast_setup = ast.parse("pass")
974 ast_setup = self.shell.compile.ast_parse("pass")
975 ast_stmt = ast.parse(transform(stmt))
975 ast_stmt = self.shell.compile.ast_parse(transform(stmt))
976 else:
976 else:
977 ast_setup = ast.parse(transform(stmt))
977 ast_setup = self.shell.compile.ast_parse(transform(stmt))
978 ast_stmt = ast.parse(transform(cell))
978 ast_stmt = self.shell.compile.ast_parse(transform(cell))
979
979
980 ast_setup = self.shell.transform_ast(ast_setup)
980 ast_setup = self.shell.transform_ast(ast_setup)
981 ast_stmt = self.shell.transform_ast(ast_stmt)
981 ast_stmt = self.shell.transform_ast(ast_stmt)
@@ -999,7 +999,7 b' python-profiler package from non-free.""")'
999 tc_min = 0.1
999 tc_min = 0.1
1000
1000
1001 t0 = clock()
1001 t0 = clock()
1002 code = compile(timeit_ast, "<magic-timeit>", "exec")
1002 code = self.shell.compile(timeit_ast, "<magic-timeit>", "exec")
1003 tc = clock()-t0
1003 tc = clock()-t0
1004
1004
1005 ns = {}
1005 ns = {}
@@ -1095,7 +1095,7 b' python-profiler package from non-free.""")'
1095 tp_min = 0.1
1095 tp_min = 0.1
1096
1096
1097 t0 = clock()
1097 t0 = clock()
1098 expr_ast = ast.parse(expr)
1098 expr_ast = self.shell.compile.ast_parse(expr)
1099 tp = clock()-t0
1099 tp = clock()-t0
1100
1100
1101 # Apply AST transformations
1101 # Apply AST transformations
@@ -1112,7 +1112,7 b' python-profiler package from non-free.""")'
1112 mode = 'exec'
1112 mode = 'exec'
1113 source = '<timed exec>'
1113 source = '<timed exec>'
1114 t0 = clock()
1114 t0 = clock()
1115 code = compile(expr_ast, source, mode)
1115 code = self.shell.compile(expr_ast, source, mode)
1116 tc = clock()-t0
1116 tc = clock()-t0
1117
1117
1118 # skew measurement as little as possible
1118 # skew measurement as little as possible
@@ -385,6 +385,7 b' def test_time3():'
385 def test_time_futures():
385 def test_time_futures():
386 "Test %time with __future__ environments"
386 "Test %time with __future__ environments"
387 ip = get_ipython()
387 ip = get_ipython()
388 ip.autocall = 0
388 ip.run_cell("from __future__ import division")
389 ip.run_cell("from __future__ import division")
389 with tt.AssertPrints('0.25'):
390 with tt.AssertPrints('0.25'):
390 ip.run_line_magic('time', 'print(1/4)')
391 ip.run_line_magic('time', 'print(1/4)')
General Comments 0
You need to be logged in to leave comments. Login now