time(n)

πŸ“¦
version 9.0.3 Β· 2 versions
  • 9.0.3 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0 (latest)
  • 8.6.10 Β· centos-stream 9
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

✨ 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 ⭐

  • script
  • time

🫢 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