My code has become really slow after some last changes I have done. A searching task takes 102 seconds instead of 2-3 seconds.
I've tried using the profile
class in order to find the limiting function, and here is the output:
>>> import WebParser
>>>
>>> w = WebParser.LinksGrabber
>>>
>>> import cProfile
>>> cProfile.run("w.search('nicki minaj', 15)")
50326 function calls in 102.745 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 102.745 102.745 <string>:1(<module>)
6 0.000 0.000 0.000 0.000 Config.py:110(__getattr__)
1 0.000 0.000 102.745 102.745 LinksGrabber.py:427(search)
5 0.000 0.000 0.002 0.000 Queue.py:107(put)
911 0.040 0.000 102.726 0.113 Queue.py:150(get)
..................................
}
6836 0.022 0.000 0.022 0.000 {min}
917 0.009 0.000 0.009 0.000 {thread.allocate_lock}
3 0.000 0.000 0.000 0.000 {thread.get_ident}
3 0.000 0.000 0.000 0.000 {thread.start_new_thread}
6835 100.458 0.015 100.458 0.015 {time.sleep}
11346 0.035 0.000 0.035 0.000 {time.time}
It shows that a time.sleep
code is waiting for 100.458s
, but I can't find the code piece in my WebParser.LinksGrabber
class.
How can I use profile
to get more information about the slow piece of code?