time(n)
β¨ time(n) β the Tcl Built-In Commands era β¨
okay bestie, welcome to the time page of the Tcl Built-In Commands manual π this is literally the stopwatch of your Tcl dreams and she is so useful, no cap.
πΈ NAME πΈ
time β time the execution of a script β±οΈβ¨
π SYNOPSIS π
time script ?count?
that's it. that's the whole vibe. π«Ά
π DESCRIPTION π
okay so here's the tea π: this command calls the Tcl interpreter count times to evaluate script β or just once if count isn't specified. and then?? it hands you back a string that looks exactly like this:
503.2 microseconds per iteration
which is telling you the average amount of time required per iteration, measured in microseconds. iconic, honestly. π
and listen β the time is measured in elapsed time, not CPU time. so it's the real wall-clock girlie, the whole "how long did this actually take in the real world" situation, not the "how much brainpower did the CPU use" situation. big difference, iykyk π
π EXAMPLE π
say you wanna estimate how long it takes for a simple Tcl for loop to count to a thousand? say less:
time {
for {set i 0} {$i<1000} {incr i} {
# empty body
}
}
look at that empty body doing absolutely nothing and still getting timed. main character energy fr fr. π
π¦ SEE ALSO π¦
clock(n)β go give her a visit too, she's lovely
β KEYWORDS β
scripttime
π«Ά friendly reminder bestie: count is optional, but if you pass it, your script is running that many times. don't be out here timing a script a million times and then being shocked it took a while. π
and that's the whole page!! sending you off with love from the Tcl crew, this was time(n) β mwah, go time something cute π
β¨πΈ
π¦ where this page comes from
- alpine 3.22: tcl-doc 8.6.16-r0 Β· TCL
- alpine 3.23: tcl-doc 8.6.17-r0 Β· TCL
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl-doc 8.6.17-r1 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- arch rolling: tcl 8.6.16-1 Β· TCL
- centos-stream 10: tcl-doc 1:8.6.13-4.el10 Β· TCL AND GPL-3.0-or-later WITH bison-exception-2.2 AND BSD-3-Clause
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- Copyright (c) 1993 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms