Browse Source

Merge branch 'master' of git://github.com/necaris/FrameworkBenchmarks into necaris-master

Michael Hixson 12 years ago
parent
commit
75ff5b9571
8 changed files with 186 additions and 0 deletions
  1. 31 0
      falcon/README.md
  2. 0 0
      falcon/__init__.py
  3. 35 0
      falcon/app.py
  4. 26 0
      falcon/benchmark_config
  5. 30 0
      falcon/setup.py
  6. 30 0
      falcon/setup_py3.py
  7. 30 0
      falcon/setup_pypy.py
  8. 4 0
      toolset/setup/linux/installer.py

+ 31 - 0
falcon/README.md

@@ -0,0 +1,31 @@
+# Falcon Benchmark Test (ported from Flask example)
+
+Single file test, [app.py](app.py)
+
+## Description
+
+Falcon API framework (http://falconframework.org)
+
+### Interpreter
+
+* CPython 2.7
+* CPython 3.3
+* PyPy 2.0
+
+### 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

+ 0 - 0
falcon/__init__.py


+ 35 - 0
falcon/app.py

@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+import sys
+import json
+
+import falcon
+
+# resource endpoints
+
+class JSONResource(object):
+    def on_get(self, request, response):
+        json_data = {'message': "Hello, world!"}
+        response.body = json.dumps(json_data)
+
+
+class PlaintextResource(object):
+    def on_get(self, request, response):
+        response.set_header('Content-Type', 'text/plain')
+        response.body = b'Hello, world!'
+
+# setup
+
+app = falcon.API()
+
+json_resource = JSONResource()
+plaintext_resource = PlaintextResource()
+
+app.add_route("/json", json_resource)
+app.add_route("/plaintext", plaintext_resource)
+
+# entry point for debugging
+if __name__ == "__main__":
+    from wsgiref import simple_server
+
+    httpd = simple_server.make_server('localhost', 8080, app)
+    httpd.serve_forever()

+ 26 - 0
falcon/benchmark_config

@@ -0,0 +1,26 @@
+{
+  "framework": "falcon",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "sort": 245
+    },
+    "py3": {
+      "setup_file": "setup_py3",
+      "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "sort": 246
+    },
+    "pypy": {
+      "setup_file": "setup_pypy",
+      "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "sort": 247
+    }
+  }]
+}

+ 30 - 0
falcon/setup.py

@@ -0,0 +1,30 @@
+import subprocess
+import setup_util
+import multiprocessing
+import os
+
+bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py2/bin')
+NCPU = multiprocessing.cpu_count()
+
+proc = None
+
+
+def start(args):
+    global proc
+    proc = subprocess.Popen([
+        bin_dir + "/gunicorn",
+        "app:app",
+        "-k", "meinheld.gmeinheld.MeinheldWorker",
+        "-b", "0.0.0.0:8080",
+        '-w', str(NCPU*3),
+        "--log-level=critical"],
+        cwd="falcon")
+    return 0
+
+def stop():
+    global proc
+    if proc is None:
+        return 0
+    proc.terminate()
+    proc = None
+    return 0

+ 30 - 0
falcon/setup_py3.py

@@ -0,0 +1,30 @@
+import subprocess
+import setup_util
+import multiprocessing
+import os
+
+bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py3/bin')
+NCPU = multiprocessing.cpu_count()
+
+proc = None
+
+
+def start(args):
+    global proc
+    proc = subprocess.Popen([
+        bin_dir + "/gunicorn",
+        "app:app",
+        "-k", "meinheld.gmeinheld.MeinheldWorker",
+        "-b", "0.0.0.0:8080",
+        '-w', str(NCPU*3),
+        "--log-level=critical"],
+        cwd="falcon")
+    return 0
+
+def stop():
+    global proc
+    if proc is None:
+        return 0
+    proc.terminate()
+    proc = None
+    return 0

+ 30 - 0
falcon/setup_pypy.py

@@ -0,0 +1,30 @@
+import subprocess
+import setup_util
+import multiprocessing
+import os
+
+bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/pypy/bin')
+NCPU = multiprocessing.cpu_count()
+
+proc = None
+
+
+def start(args):
+    global proc
+    proc = subprocess.Popen([
+        bin_dir + "/gunicorn",
+        "app:app",
+        '-k', 'tornado',
+        "-b", "0.0.0.0:8080",
+        '-w', str(NCPU*3),
+        "--log-level=critical"],
+        cwd="falcon")
+    return 0
+
+def stop():
+    global proc
+    if proc is None:
+        return 0
+    proc.terminate()
+    proc = None
+    return 0

+ 4 - 0
toolset/setup/linux/installer.py

@@ -359,6 +359,10 @@ class Installer:
     easy_install('bottle==0.11.6', two=True, three=True, pypy=True)
     easy_install('bottle-sqlalchemy==0.4', two=True, three=True, pypy=True)
 
+    # Falcon
+    easy_install('Cython==0.19.1', two=True, three=True, pypy=True)
+    easy_install('falcon==0.1.6post3', two=True, three=True, pypy=True)
+
   ############################################################
   # __install_error
   ############################################################