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 primitivePlease 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
_____________________________________________ Metakit mailing list - [email protected] http://www.equi4.com/mailman/listinfo/metakit
