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 iteration
As 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.
Get Exploring Expect now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.