pythonpython-3.xline-profiler

Kernprof (line_profiler): how to output result as text instead of a binary file


When running kernprof:

kernprof -l script_to_profile.py

The output is stored in a binary file, which can be read in the terminal/command line.

Is there a way to output the results to a text file?

This seems like useful functionality to have, but can't find it in the documentation or in other posts.


Solution

  • python -m line_profiler script_to_profile.py.lprof > profile_output.txt
    

    Will convert the binary output to a text file (thanks @martineau)