TCL - how do I know how long a function worked?

Say I have proc , and proc consists of several statements and function calls. How can I find out how much time a function has earned so far?

+3
source share
4 answers

a very crude example would be something like this:

set TIME_start [clock clicks -milliseconds]
...do something...
set TIME_taken [expr [clock clicks -milliseconds] - $TIME_start]

Using proc time, you can do the following:

% set tt [time {set x [expr 23 * 34]}]
38 microseconds per iteration
+9
source

To measure the execution time of any code, you either use timeor clock.

time script , script ( , lindex). , , script , .

clock ( , ). clock seconds, Unix ( , , , , - ). , clock milliseconds clock microseconds. clock clicks, , ( -milliseconds -microseconds). , - .

Tcl 8.4 ( !), time, clock seconds clock clicks ( -microseconds , - , 8.4). 8.5, . - ! ( pre-8.4, , .)

+3

, , time ( ) clock clicks, . time , ( , ). clock clicks , .

+1

If you are really looking for some kind of profiler, look at the profiler package in Tcllib: http://tcllib.sourceforge.net/doc/profiler.html

0
source

All Articles