The time Command
You may want to try different commands and algorithms to compare which is faster. You can use the timestamp command for this, but Tcl provides a built-in command called time which is more convenient.
The time command takes a command to execute and an optional iteration count. It returns a description of the time taken to execute each iteration. As an example, the following command times three iterations of "sleep 7“.
expect1.1> time {sleep 7} 3
7000327 microseconds per iterationAs you can see, each sleep took very close to 7 seconds which is what you would expect. The precise amount of time will vary from run to run depending on what else is executing at the same time, of course. So using a high iteration count can smooth out the difference and provide a more useful answer.
In some cases, it may be useful to run external performance monitors. For example, memory or network usage may be just as important to your application as CPU usage.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access