What psyco is goot at [Was: Rookie Speaks]

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Thu Jan 8 17:51:07 EST 2004


> From: Jacek Generowicz
> 
> Samuel Walters <swalters_usenet at yahoo.com> writes:
> 
> > If you'd like to see an example of both the psyco and 
> profile modules in
> > action, let me know and I'll give you some more 
> understandable code that I
> > once wrote to see what types of things psyco is good at optimizing.

As an example, check these pystone results (Python 2.3.3, psyco 1.1.1, Windows 2K SP4). Note I've upped the number of passes ...

The benchmarks with `from psyco.classes import __metaclass__` are interesting - they're counter to what one would expect from the docs - increased memory usage and decreased performance. Is this a known thing Armin, or is something going screwy on my box? It's happening consistently.

Note that psyco.profile() depends heavily on how your code works. I've got one piece of code that performs approx 5 times better with psyco.full(), but actually performs worse with psyco.profile() than without psyco at all!

Unfortunately, I can't make it available, but it's a single pass over a file (line by line), matching and extracting data using various regexes, writing lots of other files, then iterating over the other files to produce even more files. The datasets tend to be very large - 500MB+.

The main functions only get called one time each (which is probably the killer) and the bulk of the work is done inside while loops in those functions. I suspect that if I moved the contents of the main while loops to their own functions psyco.profile() would do a lot better.

No psyco
========

Pystone(1.1) time for 500000 passes = 11.9274
This machine benchmarks at 41920.2 pystones/second

psyco.full()
============

Pystone(1.1) time for 500000 passes = 2.36103
This machine benchmarks at 211772 pystones/second

09:37:27.73  memory usage: 97+ kb

psyco.profile()
===============

Pystone(1.1) time for 500000 passes = 2.41374
This machine benchmarks at 207147 pystones/second

09:39:02.90  memory usage: 50+ kb

psyco.full() with `from psyco.classes import __metaclass__`
===========================================================

Pystone(1.1) time for 500000 passes = 3.2981
This machine benchmarks at 151602 pystones/second

09:40:40.79  memory usage: 107+ kb

psyco.profile() with `from psyco.classes import __metaclass__`
==============================================================

Pystone(1.1) time for 500000 passes = 3.5345
This machine benchmarks at 141463 pystones/second

09:42:13.09  memory usage: 80+ kb

Tim Delaney




More information about the Python-list mailing list