profiler(n)
π profiler(n) β the Tcl source code profiler bestie π
okay so. this is profiler, the manual page from the Tcl Profiler corner of the world, and she is literally a little Tcl source code profiler. welcome to her page π
β¨ NAME β¨
profiler β Tcl source code profiler. that's it, that's the whole name, no cap π
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require profiler ?0.7?
::profiler::init
::profiler::dump pattern
::profiler::print ?pattern?
::profiler::reset ?pattern?
::profiler::suspend ?pattern?
::profiler::resume ?pattern?
::profiler::new-disabled
::profiler::new-enabled
::profiler::sortFunctions key
like look at her. she requires Tcl 8.5 9 and then she requires profiler, version ?0.7? if you're feeling specific π«Ά
π DESCRIPTION π
so the profiler package gives you a simple Tcl source code profiler. and when i say simple i mean it's a function-level profiler β that's the vibe. she collects only function-level information, not the more detailed line-level information. so if you were hoping for line-by-line tea, bestie, she is not that girl π
how does she even do it? she operates by redefining the Tcl proc command. iconic behaviour honestly. and profiling gets initiated via the ::profiler::init command. periodt.
π¦ COMMANDS π¦
::profiler::initβ initiate profiling β¨. every single procedure created after this command is called will be profiled. so if you wanna profile an entire application, this command must be called before any other commands. no skipping the line, babe π::profiler::dump patternβ dump profiling information for all the functions matching pattern. if no pattern is specified, you get info for all functions. the result is a list of key/value pairs that maps function names to information about that function. and the info about each function is itself a list of key/value pairs. so it's lists within lists, nested like russian dolls, we love her π
the keys she uses, and their values, are:
totalCallsβ the total number of timesfunctionNamewas called π₯callerDistβ a list of key/value pairs mapping each calling function that calledfunctionNameto the number of times it calledfunctionNameπcompileTimeβ the runtime, in clock clicks, offunctionNamethe first time that it was called β±οΈtotalRuntimeβ the sum of the runtimes of all calls offunctionNameβaverageRuntimeβ average runtime offunctionNameπdescendantTimeβ sum of the time spent in descendants offunctionNameπ³averageDescendantTimeβ average time spent in descendants offunctionNameπ
::profiler::print ?pattern?β print profiling information for all functions matching pattern. no pattern? then info about all functions gets displayed. the return result is a human readable display of the profiling information. it's giving readable, it's giving cute π::profiler::reset ?pattern?β reset profiling information for all functions matching pattern. if no pattern is specified, information will be reset for all functions. fresh start energy π::profiler::suspend ?pattern?β suspend profiling for all functions matching pattern. no pattern? profiling gets suspended for all functions. she stops gathering profiling information after this command is issued. but β and this is important β she does not erase any profiling information that has been gathered previously π βοΈ. use theresumecommand to re-enable profiling. we're just pausing, not deleting π::profiler::resume ?pattern?β resume profiling for all functions matching pattern. if no pattern is specified, profiling will be resumed for all functions. this command should be invoked after suspending the profiler in the code. wake up babe, we're profiling again β¨::profiler::new-disabledβ change the initial profiling state for new procedures. invoking this command disables profiling for all procedures created after this command, untilnew-enabledis invoked. wanna activate profiling of specific procedures? do it viaresumeπ::profiler::new-enabledβ change the initial profiling state for new procedures. invoking this command enables profiling for all procedures created after this command, untilnew-disabledis invoked. wanna prevent profiling of specific procedures? do it viasuspendπ«Ά::profiler::sortFunctions keyβ return a list of functions sorted by a particular profiling statistic π₯. supported values for key are:calls,exclusiveTime,compileTime,nonCompileTime,totalRuntime,avgExclusiveTime, andavgRuntime. the return result is a list of lists, where each sublist consists of a function name and the value of key for that function. sorted and served π
π BUGS, IDEAS, FEEDBACK π
ngl this document, and the package it describes, will undoubtedly contain bugs and other problems. it's not a flaw, it's a personality trait (it's a flaw). so please report such things in the category profiler of the Tcllib Trackers at:
http://core.tcl.tk/tcllib/reportlist
and please also report any ideas for enhancements you may have for either the package and/or the documentation. we want the ideas fr fr π‘
when proposing code changes, please provide unified diffs, i.e. the output of diff -u. that's the love language π₯°
note further that attachments are strongly preferred over inlined patches. attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. ok that's the whole instruction, go off π
π KEYWORDS π
performance, profile, speed
π§ CATEGORY π§
Programming tools
and that's the page, bestie π this little love letter was brought to you by tcllib, version 0.7, and she goes by profiler(n) β take care of her, she's iconic ππ
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms