Skip to content

Instantly share code, notes, and snippets.

@lupko
Created April 26, 2024 11:48
Show Gist options
  • Save lupko/a74d06389c8a46bd681bb9741ef3ebb1 to your computer and use it in GitHub Desktop.
Save lupko/a74d06389c8a46bd681bb9741ef3ebb1 to your computer and use it in GitHub Desktop.
urllib / ada_url bench
pip install pytest pytest-benchmark
pytest test.py
------------------------------------------------------------------------------------------- benchmark: 2 tests -------------------------------------------------------------------------------------------
Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Kops/s) Rounds Iterations
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_bench_urllib 510.0010 (1.0) 4,277.9975 (1.0) 595.2121 (1.0) 72.5041 (1.0) 591.0006 (1.0) 39.9959 (1.0) 453;387 1,680.0734 (1.0) 36008 1
test_bench_adaurl 4,808.9969 (9.43) 15,818.9978 (3.70) 5,054.4682 (8.49) 301.6624 (4.16) 5,018.9992 (8.49) 90.0000 (2.25) 224;676 197.8447 (0.12) 14057 1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
from urllib.parse import urlparse
from ada_url import parse_url
_TEST_URL = "https://example.com/resource?query=1#fragment=1"
def _urllib_parse():
urlparse(_TEST_URL)
def _adaurl_parse():
x = parse_url(_TEST_URL)
def test_bench_urllib(benchmark):
benchmark(_urllib_parse)
def test_bench_adaurl(benchmark):
benchmark(_adaurl_parse)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment