[Spambayes] Re: [Python-Dev] Re: some preliminary timings

Guido van Rossum guido@python.org
Tue, 25 Feb 2003 14:21:33 -0500


> > Long ago I knew Hammie; I believe it reads a possibly large database.
> > How much time does opening +closing the database take?  (I presume
> > that the 46 messages/second was not opening the database afresh for
> > each message.)
> 
> Hammie's since been modified to use a Berkeley database (bsddb3), so
> there's very little penalty associated with the database at startup time
> AFAICT.  The constant pickling and unpickling of objects may incur some
> penalty, but I don't think it would account for such a drastic slowdown.
> 
> Experience (and Tim ;) has tought me not to trust intuition, though.  I
> have very little experience performance tuning Python apps thus far, so
> I need to defer to someone else to devise an adequate test of the speed
> hit from pickling.  Surely someone's considered using the profiler,
> right?

Profiler, schmofiler.

I use this to time specific operations:

  t0 = time.clock()
  <action>
  t1 = time.clock()
  print t1-t0

On Unix, clock() measures CPU time.  If real time is more important
than CPU time, use time.time().  On Windows, clock() is a real time
timer that's more precise than time(), so you should always use
clock() there.

--Guido van Rossum (home page: http://www.python.org/~guido/)