最後の変更を行った後、コードが非常に遅くなりました。検索タスクには、2 ~ 3 秒ではなく 102 秒かかります。
profile
制限機能を見つけるためにクラスを使用してみましたが、出力は次のとおりです。
>>> 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}
time.sleep
コードが を待っていることを示していますが、クラス100.458s
でコード部分が見つかりません。WebParser.LinksGrabber
profile
遅いコード部分に関する詳細情報を取得するにはどうすればよいですか?