[Python-checkins] r86850 - python/branches/dmalcolm-ast-optimization-branch/Lib/__optimizer__.py
david.malcolm
python-checkins at python.org
Sun Nov 28 21:51:09 CET 2010
Author: david.malcolm
Date: Sun Nov 28 21:51:09 2010
New Revision: 86850
Log:
Time the optimizer (disabled for now)
Modified:
python/branches/dmalcolm-ast-optimization-branch/Lib/__optimizer__.py
Modified: python/branches/dmalcolm-ast-optimization-branch/Lib/__optimizer__.py
==============================================================================
--- python/branches/dmalcolm-ast-optimization-branch/Lib/__optimizer__.py (original)
+++ python/branches/dmalcolm-ast-optimization-branch/Lib/__optimizer__.py Sun Nov 28 21:51:09 2010
@@ -837,11 +837,21 @@
#class OptimizationError(Exception):
# def __init__(self
+timing = 0
+if timing:
+ try:
+ import time
+ except ImportError:
+ # "time" doesn't exist during the build process
+ timing = 0
+
from pprint import pprint
def optimize_ast(t, filename, st_blocks):
if 0:
print("optimize_ast called: %s" % filename)
if is_test_code(t, filename):
+ if timing:
+ t0 = time.time()
dot_before = to_dot(t)
try:
# pprint(st_blocks)
@@ -869,6 +879,9 @@
print('Exception during optimization of %r' % filename)
# dot_to_png(dot_before, 'before.png')
raise
+ if timing:
+ t1 = time.time()
+ print('Optimizing %r took %ss' % (filename, t1 - t0))
if 0:
print('finished optimizing')
if filename == 'optimizable.py':
More information about the Python-checkins
mailing list