O'Reilly logo

Practical Programming in Tcl & Tk, Third Edition by Brent B. Welch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performance Tuning

The time command measures the execution time of a Tcl command. It takes an optional parameter that is a repetition count:

						time {set a "Hello, World!"}1000
=> 28 microseconds per iteration
					

If you need the result of the command being timed, use set to capture the result:

puts $log "command: [time {set result [command]}]"

Time stamps in a Log

Another way to gain insight into the performance of your script is to generate log records that contain time stamps. The clock seconds value is too coarse, but you can couple it with the clock clicks value to get higher resolution measurements. Use the code shown in Example 13-1 on page 175 to calibrate the clicks per second on your system. Example 13-13 writes log records that contain ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required