2👍
Your data descibes how many times a given function was called and how much time was spent within that function.
- ncalls is the number of times that the function was called
- tottime is the total amount of time spent within that function, excluding subfunctions
- percall is the average amount of time that function took per call, or tottime/ncalls
- cumtime is the total amount of time spent within that function, including subfunctions
- percall is similar to the first percall but now for cumtime
So this tells you that a large amount of time is being spent in socket.py
. Specifically, readline
is called a few times and takes a pretty large amount of time each time. create_connection
is called only once but that takes even more time than a call to readline
. And within posixpath.py
, islink
is called a huge amount of times but takes a very small amount of time during each
Given that create_connection
is only called once(which makes sense), there’s likely not much you can do to change that.
It’s possible that you could reduce the number of times that readline
is called by figuring out when the function is called and changing your code to avoid multiple calls to readline
when one would suffice, but I don’t have enough knowledge of your code to say whether that’d be doable.
It seems very likely that you could reduce your calls to islink
but it would only make a small difference in speed.
Really the only way that you’re going to dramatically improve the speed of your code is by reducing those readline
calls so I’d focus on figuring out when it gets called and minimizing those calls.
0👍
This shows that you have 11 calls to readline that take almost 3 seconds. If you’re going to lower this, you need to stop doing (or do less of) whatever I/O you’re doing (I’m assuming, opening a file and parsing the lines).