[Patches] [ python-Patches-430948 ] Performance improvement for profiler

noreply@sourceforge.net noreply@sourceforge.net
Thu, 07 Jun 2001 12:39:31 -0700


Patches item #430948, was updated on 2001-06-06 22:29
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=430948&group_id=5470

Category: library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Fred L. Drake, Jr. (fdrake)
>Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Performance improvement for profiler

Initial Comment:
This patch adds a bit of complexity to
Profile.__init__() in an effort to reduce the overhead
of the profiler.  The essential piece of the puzzle is
that the general Profile.get_time() method is replaced
with a function which does only as much as is needed
for the underlying timer.  For example, if time.clock()
is available, it can become a PyCFunction instead of a
bound method, requires only 1 dict lookup to execute
instead of the 11 it takes to execute get_time()
without this patch.

Also removes a couple of duplicate imports from the "if
__name__ == ..." section.


----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2001-06-07 12:39

Message:
Logged In: YES 
user_id=31435

Fine by me (and good idea!).  I'd rather see get_time_mac 
be a module-level function _get_time_mac, get_time_timer a 
module-level _get_time_timer (or, better, _get_time_list), 
and get_time_times a module-level function _get_time_times; 
and in the last case without the needless expense of reduce
():

.def _get_time_times(times=os.times):
.    t = times()
.    return t[0] + t[1]

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-06-06 22:30

Message:
Logged In: YES 
user_id=3066

I should note that this works with both 2.1.1 and 2.2,
though this is not a bugfix.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=430948&group_id=5470