~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to profile_imports.py

  • Committer: Martin Pool
  • Date: 2009-03-24 05:21:02 UTC
  • mfrom: (4192 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4202.
  • Revision ID: mbp@sourcefrog.net-20090324052102-8kk087b32tep3d9h
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
_total_stack = {}
27
27
_info = {}
28
28
_cur_id = 0
 
29
_timer = time.time
 
30
if sys.platform == 'win32':
 
31
    _timer = time.clock
29
32
 
30
33
 
31
34
def stack_add(name, frame_name, frame_lineno, scope_name=None):
131
134
 
132
135
    this = stack_add(extra + name, frame_name, frame_lineno, scope_name)
133
136
 
134
 
    tstart = time.time()
 
137
    tstart = _timer()
135
138
    try:
136
139
        # Do the import
137
140
        mod = _real_import(name, globals, locals, fromlist)
138
141
    finally:
139
 
        tload = time.time()-tstart
 
142
        tload = _timer()-tstart
140
143
        stack_finish(this, tload)
141
144
 
142
145
    return mod
160
163
    frame_lineno = frame.f_lineno
161
164
    this = stack_add(extra+repr(args[0]), frame_name, frame_lineno)
162
165
 
163
 
    tstart = time.time()
 
166
    tstart = _timer()
164
167
    try:
165
168
        # Measure the compile time
166
169
        comp = _real_compile(*args, **kwargs)
167
170
    finally:
168
 
        tcompile = time.time() - tstart
 
171
        tcompile = _timer() - tstart
169
172
        stack_finish(this, tcompile)
170
173
 
171
174
    return comp