Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add simple pyramid benchmark #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
$BINARY -m venv $ENV
$ENV/bin/pip install -r $(dirname $0)/benchmarks/${bench}_requirements.txt
Expand Down