Skip to content

Commit 51ca70e

Browse files
committed
add simple pyramid benchmark
1 parent ee52cce commit 51ca70e

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

benchmarks/pyramid.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import json
2+
import os
3+
import requests
4+
import subprocess
5+
import sys
6+
import threading
7+
import time
8+
9+
from djangocms import waitUntilUp
10+
11+
if __name__ == "__main__":
12+
exe = sys.executable
13+
14+
times = []
15+
16+
p = subprocess.Popen([exe, "../data/pyramid_serve.py"], stdout=open("/dev/null", "w"), stderr=subprocess.STDOUT, cwd=os.path.dirname(__file__))
17+
try:
18+
waitUntilUp(("127.0.0.1", 8000))
19+
20+
n = 1800*2
21+
if len(sys.argv) > 1:
22+
n = int(sys.argv[1])
23+
24+
start = time.time()
25+
for i in range(n):
26+
times.append(time.time())
27+
if i % 100 == 0:
28+
print(i, time.time() - start)
29+
requests.get("http://localhost:8000/").text
30+
times.append(time.time())
31+
elapsed = time.time() - start
32+
print("%.2fs (%.3freq/s)" % (elapsed, n / elapsed))
33+
34+
assert p.poll() is None, p.poll()
35+
36+
finally:
37+
p.terminate()
38+
p.wait()
39+
40+
if len(sys.argv) > 2:
41+
json.dump(times, open(sys.argv[2], 'w'))

benchmarks/pyramid_requirements.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
PasteDeploy==2.1.1
2+
certifi==2020.12.5
3+
chardet==3.0.4
4+
hupper==1.10.2
5+
idna==2.10
6+
plaster==1.0
7+
plaster-pastedeploy==0.7
8+
pyramid==2.0
9+
requests==2.24.0
10+
translationstring==1.4
11+
urllib3==1.25.11
12+
venusian==3.0.0
13+
webob==1.8.7
14+
zope.deprecation==4.4.0
15+
zope.interface==5.4.0
16+

data/pyramid_serve.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from wsgiref.simple_server import make_server
2+
from pyramid.config import Configurator
3+
from pyramid.response import Response
4+
5+
def hello_world(request):
6+
return Response('Hello World!')
7+
8+
if __name__ == '__main__':
9+
with Configurator() as config:
10+
config.add_route('hello', '/')
11+
config.add_view(hello_world, route_name='hello')
12+
app = config.make_wsgi_app()
13+
server = make_server('0.0.0.0', 8000, app)
14+
server.serve_forever()
15+

run_all.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set -x
1313
mkdir -p results
1414

1515
ENV=/tmp/macrobenchmark_env
16-
for bench in flaskblogging djangocms mypy_bench pylint_bench pycparser_bench pytorch_alexnet_inference gunicorn aiohttp thrift_bench gevent_bench_hub; do
16+
for bench in flaskblogging djangocms mypy_bench pylint_bench pycparser_bench pytorch_alexnet_inference gunicorn aiohttp thrift_bench gevent_bench_hub pyramid; do
1717
rm -rf $ENV
1818
$BINARY -m venv $ENV
1919
$ENV/bin/pip install -r $(dirname $0)/benchmarks/${bench}_requirements.txt

0 commit comments

Comments
 (0)