3

I am trying to profile a slow bash script.

I have seen a few methods to do so in this question, but they all give absolute timings, or relative from one line to the next.

I would like to have timings per command / stack, to be able to dig in. A flamegraph is the perfect tool for this, but I'm not sure how I can transform the previous output into a perf-style output that can be ingested by flamegraph tool.

For reference, the current output looks like this:

+ 1679928866.341832      export LANG=en_UK.UTF-8
+ 1679928866.341900      LANG=en_UK.UTF-8
+ 1679928866.341974      test -e /Users/a770pl/.iterm2_shell_integration.bash
+ 1679928866.342025      source /Users/a770pl/.iterm2_shell_integration.bash
++ 1679928866.343111     [[ xterm-256color != screen ]]
++ 1679928866.343142     [[ '' = '' ]]
++ 1679928866.343160     [[ himxBH == *i* ]]
++ 1679928866.343191     ITERM_SHELL_INTEGRATION_INSTALLED=Yes
++ 1679928866.343214     ITERM_PREV_PS1='\h:\W \u\$ '
++ 1679928866.343234     [[ '' == \d\e\f\i\n\e\d ]]

The number of plusses is the depth in the stack, I suppose, then we have the absolute time, then the command being run.

Ciprian Tomoiagă
  • 3,773
  • 4
  • 41
  • 65
  • Please edit your question to show an example of *"a perf-style output that can be ingested"*. Good luck. – shellter Mar 28 '23 at 14:51

0 Answers0