Skip to content

Commit 3ffb867

Browse files
committed
fast api
1 parent 4e84861 commit 3ffb867

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

PerfomanceTests/readme.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ Number of successful requests in 50 seconds **(higher is better)**.
3535

3636
### Other Platforms
3737

38-
| Records | Function | AOT [1](#1-aot) | JIT [2](#2-jit) | EF [3](#3-ef) | ADO [4](#4-ado) | Django [5](#5-django) | Express [6](#6-express) | GO [6](#6-go) |
39-
| ------: | ---------: | ---------: | --------: | --------: | --------: | --------: | --------: | --------: |
40-
| 10 | `perf_test` | 423,515 | 606,410 | 337,612 | 440,896 | 21,193 | 160,241 | 78,530 |
41-
| 100 | `perf_test` | 100,542 | 126,154 | 235,331 | 314,198 | 18,345 | 58,130 | 55,119 |
42-
| 10 | `perf_test_arrays` | 292,489 | 419,707 | 254,787 | 309,059 | 19,011 | 91,987 | N/A |
43-
| 100 | `perf_test_arrays` | 68,316 | 80,906 | 113,663 | 130,471 | 11,452 | 17,896 | N/A |
38+
| Records | Function | AOT [1](#1-aot) | JIT [2](#2-jit) | EF [3](#3-ef) | ADO [4](#4-ado) | Django [5](#5-django) | Express [6](#6-express) | GO [7](#7-go) | FastAPI [8](#8-fastapi) |
39+
| ------: | ---------: | ---------: | --------: | --------: | --------: | --------: | --------: | --------: | --------: |
40+
| 10 | `perf_test` | 423,515 | 606,410 | 337,612 | 440,896 | 21,193 | 160,241 | 78,530 | 13,650 |
41+
| 100 | `perf_test` | 100,542 | 126,154 | 235,331 | 314,198 | 18,345 | 58,130 | 55,119 | 9,666 |
42+
| 10 | `perf_test_arrays` | 292,489 | 419,707 | 254,787 | 309,059 | 19,011 | 91,987 | N/A | 11,881 |
43+
| 100 | `perf_test_arrays` | 68,316 | 80,906 | 113,663 | 130,471 | 11,452 | 17,896 | N/A | 6,192 |
4444

4545
#### 1) AOT
4646

@@ -240,6 +240,8 @@ app.post('/api/perf_test_arrays', async (req, res) => {
240240

241241
go version go1.13.8
242242

243+
Note: array function endpoint tests are skipped.
244+
243245
```go
244246
package main
245247

@@ -347,6 +349,34 @@ func PerfTestFunction(w http.ResponseWriter, r *http.Request) {
347349
}
348350
```
349351

352+
#### 7) FastAPI
353+
354+
FastAPI 0.110.0 on Python 3.8
355+
356+
```py
357+
@app.post("/api/perf_test")
358+
async def perf_test(request: Request):
359+
conn = get_db_connection()
360+
cursor = conn.cursor()
361+
json = await request.json()
362+
with conn.cursor() as cursor:
363+
cursor.execute(
364+
"select id1, foo1, bar1, datetime1, id2, foo2, bar2, datetime2, long_foo_bar, is_foobar from perf_test(_records => %s, _text_param => %s, _int_param => %s, _ts_param => %s, _bool_param => %s)",
365+
[json["_records"], json["_text_param"], json["_int_param"], json["_ts_param"], json["_bool_param"]])
366+
return cursor.fetchall()
367+
368+
@app.post("/api/perf_test_arrays")
369+
async def perf_test(request: Request):
370+
conn = get_db_connection()
371+
cursor = conn.cursor()
372+
json = await request.json()
373+
with conn.cursor() as cursor:
374+
cursor.execute(
375+
"select id1, foo1, bar1, datetime1, id2, foo2, bar2, datetime2, long_foo_bar, is_foobar from perf_test_arrays(_records => %s, _text_param => %s, _int_param => %s, _ts_param => %s, _bool_param => %s)",
376+
[json["_records"], json["_text_param"], json["_int_param"], json["_ts_param"], json["_bool_param"]])
377+
return cursor.fetchall()
378+
```
379+
350380
## Tests Functions
351381

352382
```sql

0 commit comments

Comments
 (0)