Version 0 of Speed issues

Updated 2004-06-30 07:00:55 by RJM

This page is intended to document issues when effective execution of Tcl scripts is targeted. Please add any single topic below as to keep it as a comprehensive list. Append general comments as usual to the end of this page -- RJM.


  1. Write expr commands with the argument in curly braces whenever possible. This avoids conversion of numbers in strings and back. The speed impact may be a factor of 20 or so.
  2. Do not write procs without Arguments. Empty procs may execute approx. 4 times slower. At least speed critical procs schould be defined with a dummy argument.

RJM: Referencing to (2) I can say that I found this by accident. On a Win98 machine with 266 MHz clock, the following execution times apply:

An empty proc without Arguments:

 % proc test {} {}
 % time {test} 1000

95 microseconds per iteration

An empty proc with an Argument:

 % proc fast {x} {}
 % time {fast 5} 1000

12 microseconds per iteration

I performed several variations, also with filled body and so on. The crucial differencs lies in defining a proc with or without an argument.