UR::Na...llcount(3pm)

πŸ“¦
version 0.470 Β· 2 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

bestie, you've landed on UR::Na...llcount(3pm) and honestly? it's giving utility excellence. it's the page for ur test callcount β€” the command that collects callcount data from your running tests and dumps it all into one single file. one file. no chaos. we love that for us πŸ’…


🌸 SYNOPSIS 🌸

okay so here's the vibe, literally just type this:

# run tests in a given namespace
cd my_sandbox/TheApp
ur test run --recurse --callcount

ur test callcount --output all_tests.callcount

like, run the tests with --callcount on, then gather everything up. that's it. that's the whole ritual ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so WHY do you care about callcount data? to find unused subroutines in your code, bestie. dead code? exposed. πŸ•΅οΈβ€β™€οΈ

here's the deal: when the test suite is run with the "callcount" option, then for each *.t file run by the test suite, a corresponding *.callcount file gets created, and it contains info about how often all the defined subroutines were called. every single one.

the callcount file is a plain text file, and it's got three columns:

  1. the number of times this subroutine was called
  2. the name of the subroutine
  3. where in the code this subroutine is defined

so after you've run the test suite with sufficient coverage, the math is basically:

  • subroutines with 0 calls β†’ candidates for removal (bye girl πŸ‘‹)
  • subs with high call counts β†’ candidates for optimization (get her a glow-up πŸ’…)

periodt. that's the whole strategy.


✨ OPTIONS ✨

  • --input β€” names the *.callcount input file(s). when you're running from the command line, it accepts a list of files separated by ','s (commas, bestie). input files can also be handed over as plain, unnamed command line arguments (bare_args). when it's run as a command module inside another program, the input property can be an arrayref of pathanmes. once the inputs are figured out, any directories you gave get expanded by searching them recursively for files ending in .callcount with File::Find. and if no inputs in any form are given at all? it defaults to '.', the current directory, which means all *.callcount files under the current directory are used. cozy. 🏠
  • --output β€” the pathname to write the collected data to. and ooh, cute trick: you can use '-' to print the results to STDOUT. terminal printer go brrr πŸ–¨οΈ
  • --sort β€” how the collected results should be sorted before being reported. the default is 'count', which sorts incrementally by call count (that's the first column). 'sub' instead performs a string sort by subroutine name (column 2). pick your fighter βš”οΈ

πŸ‘‘ execute() πŸ‘‘

the execute() method returns an arrayref of data sorted in the appropriate way (aka whatever your --sort said). each element of that arrayref is itself an arrayref of three items: count, sub name, and sub location. three lil items, one tidy package. πŸŽ€


ngl bestie, this one's genuinely iconic β€” zero-call subs are just sitting there taking up space and this page hands you the receipts. no cap. πŸ’€βœ¨

and that's the whole page, fr fr β€” it's from the User Contributed Perl Documentation, perl v5.32.1, dated 2022-01-17, and the page itself is UR::Na...llcount(3pm). go forth and count some calls, queen πŸ«ΆπŸŒΈπŸ¦‹

πŸ“¦ where this page comes from