time manual page - Built-In Commands

Tcl8.6.9/Tk8.6.9 Documentation > Tcl Commands, version 8.6.9 > time

Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API


time — Time the execution of a script


time script ?count?


This command will call the Tcl interpreter count times to evaluate script (or once if count is not specified). It will then return a string of the form

503.2 microseconds per iteration

which indicates the average amount of time required per iteration, in microseconds. Time is measured in elapsed time, not CPU time.


Estimate how long it takes for a simple Tcl for loop to count to a thousand:

time {
    for {set i 0} {$i<1000} {incr i} {
        # empty body




script, time
Copyright © 1993 The Regents of the University of California.
Copyright © 1994-1996 Sun Microsystems, Inc.