Profiling C + Python (SWIG)

I have python code with C libraries, I use SWIG to connect it all together. I would like to profile C. libraries

I compiled them with -pg , but the profiling result is not generated ... Is there a way to profile such mixed code?

+4
source share
1 answer

You can use Valgrind using the Callgrind module (built-in). This will create a file that can appear in KCacheGrind, which is available on most Linux distributions.

To limit profiling only to your code, use the collection parameter restriction , this will allow Python to work at almost full speed, and only your code will profile (which will run about 10x slower).

Note. I have not tried this with Python myself, but it worked in similar situations.

+3
source

Source: https://habr.com/ru/post/1399336/


All Articles