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.
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.
MSW: Actually calling a proc without an argument. For comparison:
% time {test} 1000 12 microseconds per iteration % time {fast 5} 1000 3 microseconds per iteration % proc maybe {{empty {}}} {} % time {maybe} 1000 13 microseconds per iteration % time {maybe empty} 1000 3 microseconds per iteration
MS This is Bug #458361 [L1 ], but the interpretation is wrong: it is not proc calls without arguments that are slow, but rather scripts that consist of a single word and whose string equals a command name - which significantly reduces the likelihood of hitting the bug. Even adding a space to the script destroys the effect. Witness
% proc maybe {{empty {}}} {} % # call with argument % time {maybe empty} 10000 4 microseconds per iteration % # call without argument % time {maybe} 10000 19 microseconds per iteration % # call without argument; space added % time {maybe } 10000 3 microseconds per iteration % # call without argument; semicolon added % time {maybe;} 10000 4 microseconds per iteration % complex script, call with arguments % time {maybe empty; maybe empty} 10000 7 microseconds per iteration % # complex script, call without arguments % time {maybe;maybe} 10000 7 microseconds per iteration
Thanks, I have updated the issue list above accordingly --RJM
Hmmm ... not sure about the update; thinking about how to revise it. --MS