py-spy
Sampling profiler for Python programs
... line of the python program you want to run. py-spy has three subcommands record, top and dump. py-spy supports recording profiles to a file using the record command. Top shows a live view of what functions are taking the most time in your python program, similar to the Unix top command.