Created
April 16, 2013 04:56
-
-
Save toritori0318/5393456 to your computer and use it in GitHub Desktop.
httplib2/urllib2/requestsのベンチマーク
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from benchmarker import Benchmarker | |
import urllib2 | |
import httplib2 | |
import requests | |
h = httplib2.Http() | |
with Benchmarker(loop=3000) as bm: | |
for _ in bm.empty(): ## empty loop | |
pass | |
for _ in bm('httplib2'): | |
resp, content = h.request("http://maclocal:5000/", "POST") | |
for _ in bm('urllib2'): | |
urllib2.urlopen('http://maclocal:5000/', '') | |
for _ in bm('requests'): | |
r = requests.post(url='http://maclocal:5000/', data={}, headers={'Connection':'close'}) | |
###################################################### | |
% python benchmark.py <master ✗> | |
## benchmarker: release 3.0.1 (for python) | |
## python platform: darwin [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)] | |
## python version: 2.7.2 | |
## python executable: /Users/toriitsuyoshi/.pythonbrew/pythons/Python-2.7.2/bin/python | |
## user sys total real | |
(Empty) 0.0000 0.0000 0.0000 0.0004 | |
httplib2 1.6700 0.5000 2.1700 2.9435 | |
urllib2 1.0800 0.3800 1.4600 2.8499 | |
requests 6.4600 0.7300 7.1900 9.2757 | |
## Ranking real | |
urllib2 2.8499 (100.0%) ************************* | |
httplib2 2.9435 ( 96.8%) ************************ | |
requests 9.2757 ( 30.7%) ******** | |
## Ratio Matrix real [01] [02] [03] | |
[01] urllib2 2.8499 100.0% 103.3% 325.5% | |
[02] httplib2 2.9435 96.8% 100.0% 315.1% | |
[03] requests 9.2757 30.7% 31.7% 100.0% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment