From ea0fa62b450d6ee4407cd5d4194328fb971f7751 Mon Sep 17 00:00:00 2001 From: monosans Date: Fri, 2 Jun 2023 20:17:37 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20TESTS:=20Add=20pyromark=20to=20b?= =?UTF-8?q?enchmarks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benchmarking/bench_packages.py | 8 ++++++++ docs/performance.md | 26 ++++++++++++++------------ pyproject.toml | 1 + 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/benchmarking/bench_packages.py b/benchmarking/bench_packages.py index 084557a9..aa4a6724 100644 --- a/benchmarking/bench_packages.py +++ b/benchmarking/bench_packages.py @@ -76,3 +76,11 @@ def test_panflute(benchmark, spec_text): benchmark( panflute.convert_text, spec_text, input_format="markdown", output_format="html" ) + + +@pytest.mark.benchmark(group="packages") +def test_pyromark(benchmark, spec_text): + import pyromark + + benchmark.extra_info["version"] = pyromark.__version__ + benchmark(pyromark.markdown, spec_text) diff --git a/docs/performance.md b/docs/performance.md index d75c2159..ae3324f5 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -9,20 +9,22 @@ or you can run it for yourself within the repository: tox -e py311-bench-packages -- --benchmark-columns mean,stddev ``` -| package | version | mean (ms) | stddev | -| -------------------- | ------- | --------- | ------- | -| markdown-it-pyrs[^1] | 0.2.1 | 6.410 | 0.426 | -| mistune[^2] | 3.0.1 | 80.409 | 2.335 | -| **markdown-it-py** | 3.0.0 | 97.242 | 4.427 | -| mistletoe | 1.1.0 | 99.633 | 4.628 | -| commonmark-py | 0.9.1 | 300.403 | 9.706 | -| pymarkdown | 3.4.3 | 387.775 | 10.394 | -| pymarkdown (+extras) | 3.4.3 | 646.564 | 11.316 | -| panflute | 2.3.0 | 860.105 | 208.607 | +| package | version | mean (ms) | stddev | +| -------------------- | ------- | --------- | ------ | +| pyromark[^1] | 0.2.0 | 1.123 | 0.029 | +| markdown-it-pyrs[^2] | 0.2.2 | 5.167 | 0.159 | +| **markdown-it-py** | 3.0.0 | 84.969 | 3.028 | +| mistletoe | 1.1.0 | 86.625 | 2.830 | +| mistune[^3] | 3.0.1 | 92.804 | 2.495 | +| commonmark-py | 0.9.1 | 258.978 | 9.344 | +| pymarkdown | 3.4.3 | 334.764 | 0.325 | +| pymarkdown (+extras) | 3.4.3 | 595.462 | 11.333 | +| panflute | 2.3.0 | 1020.401 | 2.806 | As you can see, `markdown-it-py` doesn't pay with speed for it's flexibility. -[^1]: `markdown-it-pyrs` is a Rust implementation of `markdown-it-py`'s parser, in beta development, check it out at: -[^2]: `mistune` is not CommonMark compliant, which is what allows for its +[^1]: `pyromark` is written in Rust. It wins in performance, but is currently inferior in advanced functionality. +[^2]: `markdown-it-pyrs` is a Rust implementation of `markdown-it-py`'s parser, in beta development, check it out at: +[^3]: `mistune` is not CommonMark compliant, which is what allows for its faster parsing, at the expense of issues, for example, with nested inline parsing. See [mistletoes's explanation](https://github.com/miyuchina/mistletoe/blob/master/performance.md) for further details. diff --git a/pyproject.toml b/pyproject.toml index 46cbc762..66cc905c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ compare = [ "mistune~=3.0", "panflute~=2.3", "markdown-it-pyrs", + "pyromark~=0.2.0", ] linkify = ["linkify-it-py>=1,<3"] plugins = ["mdit-py-plugins"]