Selaa lähdekoodia

added cherrypy with plaintext and json tests

Keith Newman 10 vuotta sitten
vanhempi
commit
7e9b56db7f

+ 25 - 0
frameworks/Python/cherrypy/README.md

@@ -0,0 +1,25 @@
+# Falcon Benchmark Test (ported from Flask example)
+
+Single file test, [app.py](app.py)
+
+## Description
+
+Falcon API framework (http://falconframework.org)
+
+### Database
+
+(none at the moment)
+
+### Server
+
+* gunicorn+meinheld on CPython
+* Tornado on PyPy
+
+## Test URLs
+### JSON Encoding
+
+http://localhost:8080/json
+
+### Plaintext
+
+http://localhost:8080/plaintext

+ 18 - 0
frameworks/Python/cherrypy/app.py

@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+import cherrypy
+
+class CherryPyBenchmark(object):
+
+    @cherrypy.expose
+    @cherrypy.tools.json_out()
+    def json(self):
+        cherrypy.response.headers["Content-Type"] = "application/json"
+        json_message = {"message": "Hello, world!"}
+        return json_message  
+
+    @cherrypy.expose    
+    def plaintext(self):
+        return "Hello, world!"
+
+if __name__ == "__main__":
+    cherrypy.quickstart(CherryPyBenchmark())

+ 11 - 0
frameworks/Python/cherrypy/bash_profile.sh

@@ -0,0 +1,11 @@
+export PY2_ROOT=$IROOT/py2
+export PY2=$PY2_ROOT/bin/python
+export PY2_PIP=$PY2_ROOT/bin/pip
+
+export PYPY_ROOT=$IROOT/pypy
+export PYPY=$PYPY_ROOT/bin/python
+export PYPY_PIP=$PYPY_ROOT/bin/pip
+
+export PY3_ROOT=$IROOT/py3
+export PY3=$PY3_ROOT/bin/python
+export PY3_PIP=$PY3_ROOT/bin/pip3

+ 22 - 0
frameworks/Python/cherrypy/benchmark_config

@@ -0,0 +1,22 @@
+{
+  "framework": "cherrypy",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "None",
+      "framework": "cherrypy",
+      "language": "Python",
+      "orm": "Raw",
+      "platform": "CherryPy",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "cherrypy"
+    }
+  }]
+}

+ 27 - 0
frameworks/Python/cherrypy/gunicorn_conf.py

@@ -0,0 +1,27 @@
+import multiprocessing
+import os
+import sys
+
+_is_pypy = hasattr(sys, 'pypy_version_info')
+_is_travis = os.environ.get('TRAVIS') == 'true'
+
+# falcon only implements json and plain. Not wait DB.
+workers = multiprocessing.cpu_count()  # *3
+if _is_travis:
+    workers = 2
+
+bind = "0.0.0.0:8080"
+keepalive = 120
+errorlog = '-'
+pidfile = 'gunicorn.pid'
+
+if _is_pypy:
+    worker_class = "tornado"
+else:
+    worker_class = "meinheld.gmeinheld.MeinheldWorker"
+
+    def post_fork(server, worker):
+        # Disalbe access log
+        import meinheld.server
+        meinheld.server.set_access_logger(None)
+

+ 19 - 0
frameworks/Python/cherrypy/install.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+mkdir -p $IROOT/.pip_cache
+export PIP_DOWNLOAD_CACHE=$IROOT/.pip_cache
+
+fw_depends python2 
+#python3 pypy
+
+wget https://pypi.python.org/packages/source/C/CherryPy/CherryPy-3.6.0.tar.gz -O cherrypy.tar.gz
+tar -zxvf cherrypy.tar.gz
+cd CherryPy-3.6.0
+sudo python setup.py install
+
+
+#$PY2_PIP install --install-option="--prefix=${PY2_ROOT}" -r $TROOT/requirements.txt
+
+#$PY3_PIP install --install-option="--prefix=${PY3_ROOT}" -r $TROOT/requirements.txt
+
+#$PYPY_PIP install --install-option="--prefix=${PYPY_ROOT}" -r $TROOT/requirements-pypy.txt

+ 3 - 0
frameworks/Python/cherrypy/requirements-pypy.txt

@@ -0,0 +1,3 @@
+gunicorn==19.1
+tornado==3.2.2
+falcon==0.1.9

+ 1 - 0
frameworks/Python/cherrypy/requirements.txt

@@ -0,0 +1 @@
+cherrypy==3.6.0

+ 3 - 0
frameworks/Python/cherrypy/setup.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+python app.py &

+ 3 - 0
frameworks/Python/cherrypy/setup_py3.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+$PY3_GUNICORN app:app -c gunicorn_conf.py &

+ 3 - 0
frameworks/Python/cherrypy/setup_pypy.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+$PYPY_GUNICORN app:app -c gunicorn_conf.py &