Python profiling on Windows as you ignore built-in functions

I could not find anywhere on the Internet. I searched to find out, using the profiler, how best to optimize my code, and when sorting by what functions are used in most cases in the aggregate, things like str (), printing, and other similar widely used functions absorb most of the profile . What is the best way to profile a python program to get custom functions just to see which areas of their code they can optimize?

I hope this makes sense, any light that you can shed on this topic will be greatly appreciated.

+3
source share
1 answer

OK, I suppose your real goal is to make your code as fast as possible, right?

It is natural to assume that you are doing this by figuring out how long your functions have been running, but there is another way to look at it.

Think about how your program works, it tracks a call tree that looks like a real tree outside of your window. A line is similar to a function mainand where any branch comes off from it, like a call to another function.

Suppose that each β€œleaf” takes a certain amount of time, and what you want to do is trim the tree to remove as many leaves as possible.

- . - , . , , .

- , 10, . , , . , , , .

. , . . ( , ) . , 40%, , , .

, , . , , "". , .

+8

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


All Articles