[Metakit] Performance comparison Q - results

Jean-Claude Wippler jcw at equi4.com
Mon May 9 23:14:30 CEST 2005


Here are some performance figures, as promised.  All timings were  
done on a PIII/650 laptop with Gentoo Linux 2.6.10, gcc 3.3.5 on May  
9, 2005.

The task: calculate the sum of a list containing the numbers 0..49999.

     C                0.6 mSec      array of ints

     Python loop     72   mSec      for & s += x (or s += data[i])
     Python reduce   36   mSec      reduce(operator.add,data)
     Python sum      18   mSec      built-in sum()

     Tcl foreach     37   mSec      foreach & incr
     Tcl for         44   mSec      for & incr & lindex

     Thrill vec      24   mSec      0 swap { @ + } rep*
     Thrill ints      5   mSec      convert to int vec & use C primitive

Please take these figures with a grain of salt.  I've not  
investigated memory use.

That's Python 2.4.3 and Tcl 8.4.6, BTW.  Let me add that my first  
naive timings for Tcl were 8x slower - which shows how easy it is to  
go wrong in performance measurements.

The last two entries use a Forth'ish language I've been using in the  
Vlerq research project.

These results look promising because it seems to indicate that I  
could adopt Thrill's generic interpreted code for now, without  
performance problems.  The C code is obviously in a different league,  
but this particular operation is included as primitive in Thrill, so  
special-casing is right around the corner.

Thanks Brian, Jeff, Gary, Magnus, Bruce, Jacob, this was most  
enlightening.

-jcw



More information about the Metakit mailing list