[Patches] [ python-Patches-868736 ] Add GC collection to timeit

SourceForge.net noreply at sourceforge.net
Thu Jan 1 11:48:51 EST 2004


Patches item #868736, was opened at 2004-01-01 03:54
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=868736&group_id=5470

Category: Library (Lib)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Raymond Hettinger (rhettinger)
Summary: Add GC collection to timeit

Initial Comment:
This patch adds a gc.collect() before each timing.

Since timings are only relevant when compared to other
timings, it makes sense to put them on as equal footing
as possible.  Running a gc.collect() before each timing
provides some assurance that a routine gc collection
won't throw-off one timing while not affecting another.

At worst, this patch does nothing.  At best, it makes
the timings more comparable.

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

>Comment By: Tim Peters (tim_one)
Date: 2004-01-01 11:48

Message:
Logged In: YES 
user_id=31435

Nope, gc is no longer optional.

It may (or may not ...) be better to disable gc than to run it 
in this context, as running gc will blow the cache (by chasing 
every container object, and at least visiting every contained 
object, in existence).  That effect is much worse than just 
letting gc run naturally (forcing collection chews through all 
generations; letting it run naturally usually just looks at the 
youngest generation).

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2004-01-01 11:17

Message:
Logged In: YES 
user_id=6380

Good idea.

(I don't remember -- is it still possible to build Python
without gc? If it is, the gc import and use should be
conditional. But I vaguely remember it's no longer optional.)

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

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



More information about the Patches mailing list