From 51ca70e31bbf5adb95398c3f9505dbd3517cdb13 Mon Sep 17 00:00:00 2001 From: Marius Wachtler Date: Mon, 26 Apr 2021 11:39:39 +0200 Subject: [PATCH] add simple pyramid benchmark --- benchmarks/pyramid.py | 41 +++++++++++++++++++++++++++++ benchmarks/pyramid_requirements.txt | 16 +++++++++++ data/pyramid_serve.py | 15 +++++++++++ run_all.sh | 2 +- 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 benchmarks/pyramid.py create mode 100644 benchmarks/pyramid_requirements.txt create mode 100644 data/pyramid_serve.py diff --git a/benchmarks/pyramid.py b/benchmarks/pyramid.py new file mode 100644 index 0000000..4cf6bf5 --- /dev/null +++ b/benchmarks/pyramid.py @@ -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')) diff --git a/benchmarks/pyramid_requirements.txt b/benchmarks/pyramid_requirements.txt new file mode 100644 index 0000000..838e022 --- /dev/null +++ b/benchmarks/pyramid_requirements.txt @@ -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 + diff --git a/data/pyramid_serve.py b/data/pyramid_serve.py new file mode 100644 index 0000000..783dc60 --- /dev/null +++ b/data/pyramid_serve.py @@ -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() + diff --git a/run_all.sh b/run_all.sh index 68bd24e..de26239 100755 --- a/run_all.sh +++ b/run_all.sh @@ -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