~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to profile_imports.py

  • Committer: John Arbash Meinel
  • Date: 2008-09-09 15:09:12 UTC
  • mto: This revision was merged to the branch mainline in revision 3699.
  • Revision ID: john@arbash-meinel.com-20080909150912-wyttm8he1zsls2ck
Use the right timing function on win32

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