diff --git a/doc_src/language.rst b/doc_src/language.rst index 3d9eb41f5..36f6d1070 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -1996,4 +1996,24 @@ To start a debug session simply insert the :doc:`builtin command ` function. -If you specifically want to debug performance issues, :program:`fish` can be run with the ``--profile /path/to/profile.log`` option to save a profile to the specified path. This profile log includes a breakdown of how long each step in the execution took. See :doc:`fish ` for more information. +Profiling fish scripts +^^^^^^^^^^^^^^^^^^^^^^ + +If you specifically want to debug performance issues, :program:`fish` can be run with the ``--profile /path/to/profile.log`` option to save a profile to the specified path. This profile log includes a breakdown of how long each step in the execution took. + +For example:: + + > fish --profile /tmp/sleep.prof -ic 'sleep 3s' + > cat /tmp/sleep.prof + Time Sum Command + 3003419 3003419 > sleep 3s + +This will show the time for each command itself in the first column, the time for the command and every subcommand (like any commands inside of a :ref:`function ` or :ref:`command substitutions `) in the second and the command itself in the third, separated with tabs. + +The time is given in microseconds. + +To see the slowest commands last, ``sort -nk2 /path/to/logfile`` is useful. + +For profiling fish's startup there is also ``--profile-startup /path/to/logfile``. + +See :doc:`fish ` for more information.