Skip to content

Commit

Permalink
add simple pyramid benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
undingen committed Apr 26, 2021
1 parent c1afb8e commit 4cb2c56
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
41 changes: 41 additions & 0 deletions benchmarks/pyramid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import json
import os
import requests
import subprocess
import sys
import threading
import time

from djangocms import waitUntilUp

if __name__ == "__main__":
exe = sys.executable

times = []

p = subprocess.Popen([exe, "../data/pyramid_serve.py"], stdout=open("/dev/null", "w"), stderr=subprocess.STDOUT, cwd=os.path.dirname(__file__))
try:
waitUntilUp(("127.0.0.1", 8000))

n = 1800*2
if len(sys.argv) > 1:
n = int(sys.argv[1])

start = time.time()
for i in range(n):
times.append(time.time())
if i % 100 == 0:
print(i, time.time() - start)
requests.get("http://localhost:8000/").text
times.append(time.time())
elapsed = time.time() - start
print("%.2fs (%.3freq/s)" % (elapsed, n / elapsed))

assert p.poll() is None, p.poll()

finally:
p.terminate()
p.wait()

if len(sys.argv) > 2:
json.dump(times, open(sys.argv[2], 'w'))
16 changes: 16 additions & 0 deletions benchmarks/pyramid_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PasteDeploy==2.1.1
certifi==2020.12.5
chardet==3.0.4
hupper==1.10.2
idna==2.10
plaster==1.0
plaster-pastedeploy==0.7
pyramid==2.0
requests==2.24.0
translationstring==1.4
urllib3==1.25.11
venusian==3.0.0
webob==1.8.7
zope.deprecation==4.4.0
zope.interface==5.4.0

15 changes: 15 additions & 0 deletions data/pyramid_serve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response

def hello_world(request):
return Response('Hello World!')

if __name__ == '__main__':
with Configurator() as config:
config.add_route('hello', '/')
config.add_view(hello_world, route_name='hello')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8000, app)
server.serve_forever()

2 changes: 1 addition & 1 deletion run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set -x
mkdir -p results

ENV=/tmp/macrobenchmark_env
for bench in flaskblogging djangocms mypy_bench pylint_bench pycparser_bench pytorch_alexnet_inference gunicorn aiohttp thrift_bench gevent_bench_hub; do
for bench in flaskblogging djangocms mypy_bench pylint_bench pycparser_bench pytorch_alexnet_inference gunicorn aiohttp thrift_bench gevent_bench_hub pyramid; do
rm -rf $ENV
virtualenv -p $BINARY $ENV
$ENV/bin/pip install -r benchmarks/${bench}_requirements.txt
Expand Down

0 comments on commit 4cb2c56

Please sign in to comment.