Show More
@@ -1261,6 +1261,7 b' python-profiler package from non-free.""")' | |||
|
1261 | 1261 | # Minimum time above which compilation time will be reported |
|
1262 | 1262 | tc_min = 0.1 |
|
1263 | 1263 | |
|
1264 | expr_val=None | |
|
1264 | 1265 | if len(expr_ast.body)==1 and isinstance(expr_ast.body[0], ast.Expr): |
|
1265 | 1266 | mode = 'eval' |
|
1266 | 1267 | source = '<timed eval>' |
@@ -1268,6 +1269,15 b' python-profiler package from non-free.""")' | |||
|
1268 | 1269 | else: |
|
1269 | 1270 | mode = 'exec' |
|
1270 | 1271 | source = '<timed exec>' |
|
1272 | # multi-line %%time case | |
|
1273 | if len(expr_ast.body) > 1 : | |
|
1274 | expr_val=expr_ast.body[-1] | |
|
1275 | code_val = self.shell.compile(ast.Expression(expr_val.value) | |
|
1276 | , '<timed eval>' | |
|
1277 | , 'eval') | |
|
1278 | expr_ast=expr_ast.body[:-1] | |
|
1279 | expr_ast = ast.Module(expr_ast) | |
|
1280 | ||
|
1271 | 1281 | t0 = clock() |
|
1272 | 1282 | code = self.shell.compile(expr_ast, source, mode) |
|
1273 | 1283 | tc = clock()-t0 |
@@ -1289,11 +1299,15 b' python-profiler package from non-free.""")' | |||
|
1289 | 1299 | st = clock2() |
|
1290 | 1300 | try: |
|
1291 | 1301 | exec(code, glob, local_ns) |
|
1302 | out=None | |
|
1303 | # multi-line %%time case | |
|
1304 | if expr_val and isinstance(expr_val, ast.Expr): | |
|
1305 | out = eval(code_val, glob, local_ns) | |
|
1292 | 1306 | except: |
|
1293 | 1307 | self.shell.showtraceback() |
|
1294 | 1308 | return |
|
1295 | 1309 | end = clock2() |
|
1296 | out = None | |
|
1310 | ||
|
1297 | 1311 | wall_end = wtime() |
|
1298 | 1312 | # Compute actual times and report |
|
1299 | 1313 | wall_time = wall_end-wall_st |
General Comments 0
You need to be logged in to leave comments.
Login now