George Sakkis 7 gadi atpakaļ
vecāks
revīzija
b12796b563

+ 1 - 0
.travis.yml

@@ -171,6 +171,7 @@ env:
     - "TESTDIR=Python/klein"
     - "TESTDIR=Python/morepath"
     - "TESTDIR=Python/pyramid"
+    - "TESTDIR=Python/sanic"
     - "TESTDIR=Python/tornado"
     - "TESTDIR=Python/turbogears"
     - "TESTDIR=Python/uvicorn"

+ 21 - 0
frameworks/Python/sanic/README.md

@@ -0,0 +1,21 @@
+# Sanic Benchmark Test
+
+This is the Sanic portion of a [benchmarking tests suite](../../)
+comparing a variety of web development platforms.
+
+The information below is specific to Sanic. For further guidance,
+review the [documentation](http://frameworkbenchmarks.readthedocs.org/en/latest/).
+Also note that there is additional information provided in
+the [Python README](../).
+
+## Description
+
+[Sanic](https://sanic.readthedocs.io/en/latest/) is a Flask-like Python 3.5+
+web server that’s written to go fast.
+
+## Test Paths & Sources
+
+All of the test implementations are located within a single file ([app.py](app.py)).
+
+* [JSON Serialization](app.py): "/json"
+* [Plaintext](app.py): "/plaintext"

+ 29 - 0
frameworks/Python/sanic/app.py

@@ -0,0 +1,29 @@
+import multiprocessing
+from wsgiref.handlers import format_date_time
+
+import sanic
+from sanic import response
+
+
+app = sanic.Sanic()
+
+
[email protected]('/json')
+def json_view(request):
+    return response.json({'message': 'Hello, world!'}, headers=get_headers())
+
+
[email protected]('/plaintext')
+def plaintext_view(request):
+    return response.text('Hello, world!', headers=get_headers())
+
+
+def get_headers(server='Sanic/{}'.format(sanic.__version__)):
+    return {
+        'Server': server,
+        'Date': format_date_time(None),
+    }
+
+if __name__ == '__main__':
+    app.run('0.0.0.0', 8080, access_log=False,
+            workers=multiprocessing.cpu_count())

+ 24 - 0
frameworks/Python/sanic/benchmark_config.json

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

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

@@ -0,0 +1 @@
+sanic==0.7.0

+ 7 - 0
frameworks/Python/sanic/setup.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+fw_depends python3
+
+pip3 install --install-option="--prefix=${PY3_ROOT}" -r $TROOT/requirements.txt
+
+python3 app.py &