make faster Richards benchmark

Duncan Lissett dlissett0 at yahoo.com
Fri May 14 18:02:52 EDT 2004


Duncan Booth <me at privacy.net> wrote in message news:<Xns94E8683D9EEF2duncanrcpcouk at 127.0.0.1>...

-snip-
> Next most obvious thing is to junk the linked lists and replace them with 
> ordinary Python builtin lists. 

After the Packet links were replace with a Python list the code was
~1% slower...

> Replace the traceOn variable with __debug__ so you get the same benefits as 
> compiled languages by optimising out the test for the trace statements.

Using __debug__ made the code ~1% faster
 
> Remove the pointless set/get methods and just access the members directly. 

As a special dispensation to Python, directly accessed Packet and Tcb
fields, ~10% faster


> Avoiding multiple accesses to the same instance variable, or assigning to 
> instance variables until you are about to return from a method: use a local 
> during the execution of the method.

Seems we're pushing into code optimization rather than not coding
badly.

Being careful about the tests in conditionals, and reordering some
conditionals sped things up some more. (I should roll the same changes
into the other langauge implementations.)

The OO style implementation took 104.4s and now takes 87.1s

I took the OO style implementation, made the methods of the scheduler
class into functions, made the fields into globals, and made the Task
class run methods into top-level functions.

The C style implementation took 114.9s and the OO conversion takes
80.3s
http://www.lissett.com/ben/bench3.htm

Further suggestions are welcome (yes, I will try pysco later)



More information about the Python-list mailing list