나는 Discogs API를 파이썬과 함께 사용하는 짧은 프로그램을 작성했지만 실제 웹 응용 프로그램에는 사용할 수없는 속도가 느립니다. 비단뱀의 결과가 프로파일 여기에httplib (discogs API)의 python 성능
# -*- coding: utf-8 -*-
import profile
import discogs_client as discogs
def main():
discogs.user_agent = 'Mozilla/5.0'
#dump released albums into the file. You could also print it to the console
f=open('DiscogsTestResult.txt', 'w+')
#Use another band if you like,
#but if you decide to take "beatles" you will wait an hour! (cause of the num of releases)
artist = discogs.Artist('Faust')
print >> f, artist
print >> f," "
artistReleases = artist.releases
for r in artistReleases:
print >> f, r.data
print >> f,"---------------------------------------------"
print 'Performance Analysis of Discogs API'
print '=' * 80
profile.run('print main(); print')
과 :
Performance Analysis of Discogs API
================================================================================
82807 function calls (282219 primitive calls) in 177.544 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
188 121.013 0.644 121.013 0.644 :0(connect)
206 52.080 0.253 52.080 0.253 :0(recv)
1 0.036 0.036 177.494 177.494 <string>:1(<module>)
188 0.013 0.000 175.234 0.932 adapters.py:261(send)
376 0.005 0.000 0.083 0.000 adapters.py:94(init_poolmanager)
188 0.008 0.000 176.569 0.939 api.py:17(request)
188 0.007 0.000 176.577 0.939 api.py:47(get)
188 0.015 0.000 173.922 0.925 connectionpool.py:268(_make_request)
188 0.015 0.000 174.034 0.926 connectionpool.py:332(urlopen)
1 0.496 0.496 177.457 177.457 discogsTestFullDump.py:6(main)
564 0.009 0.000 176.613 0.313 discogs_client.py:66(_response)
188 0.012 0.000 176.955 0.941 discogs_client.py:83(data)
188 0.011 0.000 51.759 0.275 httplib.py:363(_read_status)
188 0.017 0.000 52.520 0.279 httplib.py:400(begin)
188 0.003 0.000 121.198 0.645 httplib.py:754(connect)
188 0.007 0.000 121.270 0.645 httplib.py:772(send)
188 0.005 0.000 121.276 0.645 httplib.py:799(_send_output)
188 0.003 0.000 121.279 0.645 httplib.py:941(endheaders)
188 0.003 0.000 121.348 0.645 httplib.py:956(request)
188 0.016 0.000 121.345 0.645 httplib.py:977(_send_request)
188 0.009 0.000 52.541 0.279 httplib.py:994(getresponse)
1 0.000 0.000 177.544 177.544 profile:0(print main(); print)
188 0.032 0.000 176.322 0.938 sessions.py:225(request)
188 0.030 0.000 175.513 0.934 sessions.py:408(send)
752 0.015 0.000 121.088 0.161 socket.py:223(meth)
2256 0.224 0.000 52.127 0.023 socket.py:406(readline)
188 0.009 0.000 121.195 0.645 socket.py:537(create_connection)
는 사람이 어떻게 어떤 생각을 가지고 있습니까 여기 파이썬 코드와 파이썬 프로파일 결과 (게시 시간 만 점을 소모을)입니다 이 속도를 높여 라. discogs_client.py에서 변경 사항이 더 빨라지기를 바랍니다. httplib에서 다른 것 또는 기타로 변경되었을 수 있습니다. 아니면 http 대신 다른 프로토콜을 사용하는 것이 더 빠릅니까?
은 (discogs_client.py의 소스는 여기에 액세스 할 수 있습니다 : "https://github.com/discogs/discogs_client/blob/master/discogs_client.py")
사람이 어떤 생각을 가지고 있다면 많은 사람들이 혜택을 누릴 것이라고 응답하시기 바랍니다. 감사합니다 다니엘
Didnt는 "IP 주소 당 초당 하나"를 알고 있습니다. 고맙습니다! 프리 패치를하는 것이 좋겠지 만 웹 사이트를 파싱하는 것이 더 빠를 수도 있습니다. 어쨌든 고맙습니다. – user1911091