Hi everyone,
Since currently there are no solutions for profiling Numba code, I have created one. It’s not as nice as the kind of profiling you could get if eventually Numba supports it natively, but it does seem to work in my initial tests.
Here’s an example:
$ pip install profila
$ python -m profila annotate -- scripts_for_tests/simple.py
# Total samples: 328 (54.9% non-Numba samples, 1.8% bad samples)
## File `/home/itamarst/devel/profila/scripts_for_tests/simple.py`
Lines 10 to 15:
0.3% | for i in range(len(timeseries)):
| # This should be the most expensive line:
38.7% | result[i] = (7 + timeseries[i] / 9 + (timeseries[i] ** 2) / 7) / 5
| for i in range(len(result)):
| # This should be cheaper:
4.3% | result[i] -= 1
So far I’ve only tested it on toy examples, so I’d love to get feedback from real-world usage. At the moment I’ve also only tried it on Linux, but there’s a decent chance it’ll work on macOS (you’ll need to brew install gdb
first), and it will likely work on WSL2 on Windows.
For more details see GitHub - pythonspeed/profila: A profiler for Numba