Prechádzať zdrojové kódy

Remove Python/blacksheep (#7210)

Nate 3 rokov pred
rodič
commit
4d573e3d3c

+ 0 - 38
frameworks/Python/blacksheep/README.md

@@ -1,38 +0,0 @@
-# BlackSheep Benchmark Test
-
-This is the BlackSheep portion of a [benchmarking tests suite](../../)
-comparing a variety of web development platforms.
-
-The information below is specific to BlackSheep. For further guidance,
-review the [documentation](https://github.com/TechEmpower/FrameworkBenchmarks/wiki).
-Also note that there is additional information provided in
-the [Python README](../).
-
-## Description
-
-[BlackSheep](https://github.com/RobertoPrevato/BlackSheep) is a fast HTTP Server/Client microframework for Python [asyncio](https://docs.python.org/3/library/asyncio.html), using [Cython](https://cython.org), 
-[`uvloop`](https://magic.io/blog/uvloop-blazing-fast-python-networking/), and 
-[`httptools`](https://github.com/MagicStack/httptools). 
-
-<p align="left">
-  <a href="#blacksheep"><img width="320" height="271" src="https://raw.githubusercontent.com/RobertoPrevato/BlackSheep/master/black-sheep.svg?sanitize=true" alt="Black Sheep"></a>
-</p>
-
-
-## Implementation
-
-BlackSheep is implemented using:
-
-* [asyncio](https://docs.python.org/3/library/asyncio.html).
-* [Cython](https://cython.org)
-* [`uvloop`](https://magic.io/blog/uvloop-blazing-fast-python-networking/).
-* [`httptools`](https://github.com/MagicStack/httptools).
-* Python built-in multiprocessing module.
-
-## Test Paths & Sources
-
-All of the test implementations are located within a single file ([app.py](app.py)).
-
-## Resources
-
-* [Repo](https://github.com/RobertoPrevato/BlackSheep)

+ 0 - 145
frameworks/Python/blacksheep/app.py

@@ -1,145 +0,0 @@
-import os
-import ujson
-import asyncpg
-from random import randint
-from multiprocessing import cpu_count
-from blacksheep.server import Application
-from blacksheep import Response, Header, Content
-from jinja2 import Template
-json_dumps = ujson.dumps
-
-
-async def configure_db(app):
-    global db_pool
-    db_pool = await asyncpg.create_pool(
-        user=os.getenv('PGUSER', 'benchmarkdbuser'),
-        password=os.getenv('PGPASS', 'benchmarkdbpass'),
-        database='hello_world',
-        host='tfb-database',
-        port=5432
-    )
-
-
-def load_fortunes_template():
-    path = os.path.join('templates', 'fortune.html')
-    with open(path, 'r') as template_file:
-        template_text = template_file.read()
-        return Template(template_text)
-
-
-db_pool = None
-fortune_template = load_fortunes_template()
-
-app = Application()
-app.on_start += configure_db
-
-
-def get_num_queries(request):
-    try:
-        value = request.query.get('queries')
-        if value is None:
-            return 1
-
-        query_count = int(value[0])
-    except (KeyError, IndexError, ValueError):
-        return 1
-
-    if query_count < 1:
-        return 1
-    if query_count > 500:
-        return 500
-    return query_count
-
-
[email protected]('/json')
-async def json_test(request):
-    """Test type 1: JSON Serialization"""
-
-    return Response(200, content=Content(b'application/json; charset=utf-8',
-                                         json_dumps({'message': 'Hello, world!'}).encode('utf-8')))
-
-
[email protected]('/db')
-async def single_db_query_test(request):
-    """Test type 2: Single Database Query"""
-
-    row_id = randint(1, 10000)
-    connection = await db_pool.acquire()
-    try:
-        number = await connection.fetchval('SELECT "randomnumber", "id" FROM "world" WHERE id = $1', row_id)
-        world = {'id': row_id, 'randomNumber': number}
-    finally:
-        await db_pool.release(connection)
-
-    return Response(200, content=Content(b'application/json; charset=utf-8',
-                                         json_dumps(world).encode('utf-8')))
-
-
[email protected]('/queries')
-async def multiple_db_queries_test(request):
-    """Test type 3: Multiple Database Queries"""
-
-    num_queries = get_num_queries(request)
-
-    row_ids = [randint(1, 10000) for _ in range(num_queries)]
-    worlds = []
-
-    connection = await db_pool.acquire()
-    try:
-        statement = await connection.prepare('SELECT "randomnumber", "id" FROM "world" WHERE id = $1')
-        for row_id in row_ids:
-            number = await statement.fetchval(row_id)
-            worlds.append({'id': row_id, 'randomNumber': number})
-    finally:
-        await db_pool.release(connection)
-
-    return Response(200, content=Content(b'application/json; charset=utf-8',
-                                         json_dumps(worlds).encode('utf-8')))
-
-
[email protected]('/fortunes')
-async def fortunes_test(request):
-    """Test type 4: Fortunes"""
-
-    connection = await db_pool.acquire()
-
-    try:
-        fortunes = await connection.fetch('SELECT * FROM Fortune')
-    finally:
-        await db_pool.release(connection)
-
-    fortunes.append([0, 'Additional fortune added at request time.'])
-    fortunes.sort(key=lambda x: x[1])
-
-    return Response(200, [
-        Header(b'Cache-Control', b'no-cache')
-    ], content=Content(b'text/html; charset=utf-8', fortune_template.render(fortunes=fortunes).encode('utf8')))
-
-
[email protected]('/updates')
-async def db_updates_test(request):
-    """Test type 5: Database Updates"""
-
-    num_queries = get_num_queries(request)
-
-    updates = [(randint(1, 10000), randint(1, 10000)) for _ in range(num_queries)]
-    worlds = [{'id': row_id, 'randomNumber': number} for row_id, number in updates]
-
-    connection = await db_pool.acquire()
-    try:
-        statement = await connection.prepare('SELECT "randomnumber", "id" FROM "world" WHERE id = $1')
-        for row_id, _ in updates:
-            await statement.fetchval(row_id)
-        await connection.executemany('UPDATE "world" SET "randomnumber"=$1 WHERE id=$2', updates)
-    finally:
-        await db_pool.release(connection)
-
-    return Response(200, content=Content(b'application/json',
-                                         json_dumps(worlds).encode('utf-8')))
-
-
[email protected]('/plaintext')
-async def plaintext_test(request):
-    """Test type 6: Plaintext"""
-
-    return Response(200, content=Content(b'text/plain', b'Hello, World!'))

+ 0 - 27
frameworks/Python/blacksheep/benchmark_config.json

@@ -1,27 +0,0 @@
-{
-  "framework": "blacksheep",
-  "tests": [{
-    "default": {
-      "json_url": "/json",
-      "fortune_url": "/fortunes",
-      "plaintext_url": "/plaintext",
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "update_url": "/updates?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Platform",
-      "framework": "blacksheep",
-      "language": "Python",
-      "flavor": "Python3",
-      "platform": "None",
-      "webserver": "None",
-      "os": "Linux",
-      "orm": "Raw",
-      "database_os": "Linux",
-      "database": "Postgres",
-      "display_name": "blacksheep",
-      "notes": ""
-    }
-  }]
-}

+ 0 - 17
frameworks/Python/blacksheep/blacksheep.dockerfile

@@ -1,17 +0,0 @@
-FROM python:3.8
-
-WORKDIR /blacksheep
-
-RUN pip3 install cython==0.29.13
-
-ADD requirements.txt /blacksheep/
-
-RUN pip3 install -r /blacksheep/requirements.txt
-
-ADD templates/fortune.html /blacksheep/templates/
-
-ADD blacksheep_conf.py app.py /blacksheep/
-
-EXPOSE 8080
-
-CMD gunicorn app:app -k uvicorn.workers.UvicornWorker -c blacksheep_conf.py

+ 0 - 14
frameworks/Python/blacksheep/blacksheep_conf.py

@@ -1,14 +0,0 @@
-import multiprocessing
-import os
-
-_is_travis = os.environ.get('TRAVIS') == 'true'
-
-workers = multiprocessing.cpu_count()
-if _is_travis:
-    workers = 2
-
-bind = "0.0.0.0:8080"
-keepalive = 120
-errorlog = '-'
-pidfile = '/tmp/blacksheep.pid'
-loglevel = 'error'

+ 0 - 19
frameworks/Python/blacksheep/config.toml

@@ -1,19 +0,0 @@
-[framework]
-name = "blacksheep"
-
-[main]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Platform"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "None"
-webserver = "None"
-versus = "None"

+ 0 - 7
frameworks/Python/blacksheep/requirements.txt

@@ -1,7 +0,0 @@
-asyncpg==0.21.0
-gunicorn==20.0.4
-Jinja2==2.11.3
-blacksheep==0.2.2
-ujson==2.0.3
-uvloop==0.14.0
-uvicorn==0.11.7

+ 0 - 10
frameworks/Python/blacksheep/templates/fortune.html

@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head><title>Fortunes</title></head>
-<body>
-<table>
-<tr><th>id</th><th>message</th></tr>
-{% for fortune in fortunes %}<tr><td>{{ fortune[0] }}</td><td>{{ fortune[1]|e }}</td></tr>
-{% endfor %}</table>
-</body>
-</html>