- Performance Tools
- Performance Hints
In a stock Tcl binary, you can use the time
command
to measure the execution time of a command. The
format of the command is: time
tcl_command optional_repetition_count. For example:
% time {foreach i [list a b c d e ] { lappend result $i}}
808 microseconds per iteration
% time {foreach i [list a b c d e ] { lappend result $i}} 10
259 microseconds per iteration
% time {foreach i [list a b c d e ] { lappend result $i}} 100
244 microseconds per iteration
The TclX package includes a profile
command which can be
used to return a call stack. TclX can be found at ftp://ftp.neosoft.com/pub/tcl/tclx-distrib
.
The hints below were taken from Practical
Programming in Tcl and Tk, by
Brent B. Welch, page 87.
If you are using exec
, then you may want to reconsider.
- The Tcl
exec
is not portable to non-unix platforms.
- There is a lot of overhead in starting another process. For
example, calling the Unix
date
command is fairly slow:
% time {exec date}
287316 microseconds per iteration
% time {puts [clock format [clock seconds]]}
Sun Sep 22 16:10:33 PDT 1996
1606 microseconds per iteration
%
See the Tycho Exec Internals Guide.
If your application is taking a long time to start up, try the following:
- Autoloading Itcl files takes more time than just sourcing them.
If you source the files necessary before creating your first widget,
you might see a speedup. You might find it interesting to put
puts
statements at the top of the unknown
,
tcl_unknown
and auto_load
procs in
lib/itcl/tcl/init.tcl
(if you are using Tycho from within
Ptolemy, then this file would be at $PTOLEMY/tcltk/itcl/lib/itcl/tcl/init.tcl
).
However, this link may not work for you.
Tycho Home Page
Copyright © 1996-1998, The Regents of the University of California.
All rights reserved.
Last updated: 03/15/98,
comments to: eal@eecs.berkeley.edu