Richards bench benchmark

Peter Hansen peter at engcorp.com
Sat Apr 24 22:12:52 EDT 2004


Duncan Lissett wrote:

> Peter Hansen <peter at engcorp.com> wrote in message news:<40899240.7020508 at engcorp.com>...
> 
>>Okay, first working version is available by going to 
>>http://www.engcorp.com/main/projects/PyBench .
>>
>>That's about all the time I can spare on this for now.
>>Feel free to download, hack, improve, or ignore.
> 
> Excellent! 
> 
> I've added the Python implementation timings:
> http://www.lissett.com/ben/bench1.htm
> 
> I've no prior experience of Python to judge from, but for some reason
> I expected it to be faster than the interpreted implementation of
> Smalltalk designed for mobile devices.

One key item would be to examine the function calls to append().
I'm guessing they are a substantial portion of the execution
time.  A little profiling is in order if anyone is interested
in optimizing it.

I made no effort to convert it to a Pythonic style.  It's
basically C code translated, with one small exception being
the task list which is a simple Python list object instead of
being a linked list.  That means task lookups by id using findtcb()
are quite fast, but the "work queues" used to hold the packets
are actual singly-linked lists, implemented in Python, with
a subroutine called append() used to scan the list and stick
stuff on the end.  This is absolutely, without question, not
the way anyone would write this in Python if they were not
just trying to maintain the original BCPL/C flavour intact.

I'll make a prediction: with an hour or two of work, any
good Python programmer can get a 10x speedup out of the
program.  I don't know how meaningful it will be as a
benchmark at that point, but it is probably fair to compare
with the object-oriented versions which already violate the
original specification (e.g. the Java version, and the
Smalltalk ones Duncan mentioned).

If anyone wants to improve it, feel free.  There are full
unit tests and an acceptance test in bench_test.py, even
covering the format of the output, so this could be a good
chance for someone new to unit testing to get a feel for
it by trying to modify them to drive the code in a new
direction...

-Peter



More information about the Python-list mailing list