Search code examples
timetimestamptclproc-object

TCL - how to know how much time a function has worked?


Say I have a proc and the proc consists of several statements and function calls. How I can know how much time the function has taken so far?


Solution

  • a very crude example would be something like:

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

    Using the time proc, you can do the following:

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