pyinstrument icon indicating copy to clipboard operation
pyinstrument copied to clipboard

Allow customization of target_description in the CLI

Open mgunyho opened this issue 4 months ago • 1 comments

Hi, thank you for this wonderful tool.

I am profiling a program across different git revisions, and I would like to add some additional information to the HTML output to more easily recognize which trace comes from which version. Basically, I would like to be able to customize the target_description here:

https://github.com/joerick/pyinstrument/blob/e2883335013299cd9ff7d642f299d0a94203bb08/pyinstrument/main.py#L380

Would it be possible to add a CLI option like --description that would override the value? And/or perhaps it would be useful to be able to "add" to the description, i.e. keep the original Program: {" ".join(argv)} but add an additional comment.

For now I'm saving the git hash in the name of the output file and manually saving some extra information in a txt file next to the HTML output, but it would be nice for example if I could add the git commit message of the given revision to the description that is directly shown in the HTML.

mgunyho avatar Aug 21 '25 07:08 mgunyho

sure thing. I think we could have the option of retaining the original program string using a token like {program}. e.g. pyinstrument --target-description 'abcd31 by Joe - {program}' myscript.py

Send over PR if you have time!

joerick avatar Oct 19 '25 09:10 joerick