Skip to content

Commit

Permalink
niquests benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
dvolodin7 committed Mar 6, 2024
1 parent d3e617e commit 5bc01f0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .requirements/bench.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
requests==2.31.0
httpx==0.27
aiohttp==3.9.3
aiosonic==0.18.0
aiosonic==0.18.0
niquests==3.5.2
12 changes: 12 additions & 0 deletions benchmarks/test_linear_x100_1k.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import aiohttp
import aiosonic
import httpx
import niquests
import pytest
import requests

Expand Down Expand Up @@ -76,6 +77,17 @@ def bench():
_ = resp.content


def test_niquests_sync(httpd: Httpd, benchmark) -> None:
url = f"{httpd.prefix}/bench-1k.txt"

@benchmark
def bench():
session = niquests.Session(multiplexed=True)
for _ in range(REPEATS):
resp = session.get(url)
_ = resp.content


def test_httpx_sync(httpd: Httpd, benchmark) -> None:
url = f"{httpd.prefix}/bench-1k.txt"

Expand Down
15 changes: 15 additions & 0 deletions benchmarks/test_p4_x100_1k.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import aiohttp
import aiosonic
import httpx
import niquests
import pytest
import requests

Expand Down Expand Up @@ -98,6 +99,20 @@ def bench():
run_on_threadpool(do_request)


def test_niquests_sync(httpd: Httpd, benchmark) -> None:
url = f"{httpd.prefix}/bench-1k.txt"

def do_request():
session = niquests.Session(multiplexed=True)
for _ in range(PER_TASK):
resp = session.get(url)
_ = resp.content

@benchmark
def bench():
run_on_threadpool(do_request)


def test_httpx_sync(httpd: Httpd, benchmark) -> None:
url = f"{httpd.prefix}/bench-1k.txt"

Expand Down

0 comments on commit 5bc01f0

Please sign in to comment.