profiler(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ‘‘ 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 times functionName was called πŸ”₯
  • callerDist β€” a list of key/value pairs mapping each calling function that called functionName to the number of times it called functionName πŸ‘€
  • compileTime β€” the runtime, in clock clicks, of functionName the first time that it was called ⏱️
  • totalRuntime β€” the sum of the runtimes of all calls of functionName βž•
  • averageRuntime β€” average runtime of functionName πŸ“Š
  • descendantTime β€” sum of the time spent in descendants of functionName 🌳
  • averageDescendantTime β€” average time spent in descendants of functionName πŸ“
  • ::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 the resume command 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, until new-enabled is invoked. wanna activate profiling of specific procedures? do it via resume 😌
  • ::profiler::new-enabled β€” change the initial profiling state for new procedures. invoking this command enables profiling for all procedures created after this command, until new-disabled is invoked. wanna prevent profiling of specific procedures? do it via suspend 🫢
  • ::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, and avgRuntime. 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