Does effective Cython cProfiling imply writing many sub functions?

后端 未结 2 1131
礼貌的吻别
礼貌的吻别 2021-01-27 18:10

I am trying to optimize some code with Cython, but cProfile is not providing enough information.

To do a good job at profiling, should I create many su

相关标签:
2条回答
  • 2021-01-27 18:25

    Yes, it does. The finest granularity available to cProfile is a function call. You must split up func1 into multiple functions. (Note that you can make them functions defined inside func1 and thus only available to func1.)

    If you want finer-grained profiling (line-level), then you need a different profiler. Take a look at this line-level profiler, but I don't think it works for Cython.

    0 讨论(0)
  • 2021-01-27 18:36

    You need to enable profiling support for your Cython code. Use

    # cython: profile=True
    

    http://docs.cython.org/src/tutorial/profiling_tutorial.html

    0 讨论(0)
提交回复
热议问题