Version 18 of Tcl OO Bench

Updated 2004-03-03 10:20:21

This comparison of OO extensions of Tcl is based on OO benchmarks of the OO shootout [L1 ] and consists of the OO Method calls (source [L2 ]) and the Object Instantiation Test (Source [L3 ]).

These tests were performed on a Pentium 4 M Notebook with 1400 MHz under Fedora Core 1.0 with tcl 8.4.5.

XOTcl 1.2.0

  methcall:  0.460u 0.000s 0:00.53 86.7%        0+0k 0+0io 347pf+0w
  objinst:   0.960u 0.000s 0:00.97 98.9%        0+0k 0+0io 348pf+0w

ITcl emulation in XOTcl (see Itcl in XOTcl)

  methcall:  0.590u 0.000s 0:00.62 95.1%        0+0k 0+0io 351pf+0w
  objinst:   1.760u 0.010s 0:01.74 101.7%       0+0k 0+0io 352pf+0w

MIT OTcl 1.0

  methcall:  0.980u 0.000s 0:00.95 103.1%       0+0k 0+0io 329pf+0w
  objinst:   2.370u 0.010s 0:02.37 100.4%       0+0k 0+0io 329pf+0w

itcl 3.2

  methcall:  0.870u 0.020s 0:00.92 96.7%        0+0k 0+0io 347pf+0w
  objinst:   1.790u 0.010s 0:01.84 97.8%        0+0k 0+0io 348pf+0w

stooop 4.4

  methcall:  1.640u 0.040s 0:01.73 97.1%        0+0k 0+0io 326pf+0w
  objinst:   4.030u 0.000s 0:05.75 70.0%        0+0k 0+0io 316pf+0w

classytcl 1.0

  methcall:  0.740u 0.010s 0:00.78 96.1%        0+0k 0+0io 335pf+0w
  objinst:   3.020u 0.030s 0:03.09 98.7%        0+0k 0+0io 335pf+0w

The full source and results are available at [L4 ].


Please note that for stooop, in the method call benchmark, the value procedure has no reason to be virtual since it only returns the value of a data member in its class. Removing the virtual qualifier results in a huge improvement in speed (on my Xeon 2.4 GHz Fedora 1 Linux machine, with Tcl 8.4.5):

real 0m1.668s, user 0m1.660s, sys 0m0.010s -> real 0m0.394s, user 0m0.390s, sys 0m0.010s

Jean-Luc Fontaine

GN It is true that the benchmark for stooop can be improved significantly by removing the virtual qualifier. On the same machine as above, we get the following results:

stooop 4.4

  methcall:  0.480u 0.020s 0:00.52 96.1%        0+0k 0+0io 326pf+0w
  objinst:   4.020u 0.000s 0:04.06 99.0%        0+0k 0+0io 316pf+0w

However, the benchmark specification says that ... the constructor for NthToggle should use the constructor for Toggle to inherit the boolean field and value() method. If virtual is removed, value() is not inherited, therefore the implementation is not correct.

If someone else sees improvments in the tests, please note.


Also, here are the memory consumption results, which are as interesting in my opinion:

creating 10000 objects

itcl

   Used memory: 4640768
   Memory per itcl object: 464
   Time per object: 9.43

MIT otcl

   Used memory: 2838528
   Memory per otcl object: 283
   Time per object: 17.62

XOTcl

   Used memory: 2162688
   Memory per xotcl object: 216
   Time per object: 7.72

Stooop

   Used memory: 1351680
   Memory per stooop object: 135
   Time per object: 22.36

ClassyTcl

   Used memory: 8835072
   Memory per classy tcl object: 883
   Time per object: 548

because the "namespace import xotcl::*" creates a Class command in the global namespace, the compiled version of ClassyTcl is not loaded in this test. On my system, the compiled version scores a bit better than XOTcl both on memory and time PDR

Snit

   Used memory: 20787200
   Memory per snit object: 2078
   Time per object: 2006.91

Jean-Luc