Is there a Python library that shows execution time per line?
Question:
Answers:
There is a library called pyheat
.
you can install by
pip install py-heat
and import it using from pyheat import PyHeat
Pyheat can be used to generate a heatmap of time numbers for each line of code for a Python module. Pass the path of the Python file as a parameter to the PyHeat function.
ph = PyHeat('merge_sort.py') # mergesort.py is the example given
ph.create_heatmap()
ph.show_heatmap()
Please look into this https://github.com/csurfer/pyheat
I’ve built a small library perf_tool that can perform this kind of benchmarks.
It can be used to profile pieces of codes and also single lines using decorators, here is a simple example:
from perf_tool import PerfTool
with PerfTool('test'):
<The code to be profiled>
Calling it the result is a report showing some metrics like this:
================== PerfTool ==================
task |aver(s) |sum(s) |count |std
main | 0.065| 0.065| 1| 0.000
+-test | 0.050| 0.005| 10| 0.002
There are also other libraries in that field like linetimer
There is a library called pyheat
.
you can install by
pip install py-heat
and import it using from pyheat import PyHeat
Pyheat can be used to generate a heatmap of time numbers for each line of code for a Python module. Pass the path of the Python file as a parameter to the PyHeat function.
ph = PyHeat('merge_sort.py') # mergesort.py is the example given
ph.create_heatmap()
ph.show_heatmap()
Please look into this https://github.com/csurfer/pyheat
I’ve built a small library perf_tool that can perform this kind of benchmarks.
It can be used to profile pieces of codes and also single lines using decorators, here is a simple example:
from perf_tool import PerfTool
with PerfTool('test'):
<The code to be profiled>
Calling it the result is a report showing some metrics like this:
================== PerfTool ==================
task |aver(s) |sum(s) |count |std
main | 0.065| 0.065| 1| 0.000
+-test | 0.050| 0.005| 10| 0.002
There are also other libraries in that field like linetimer