diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:24:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:24:24 +0000 |
commit | 12e8343068b906f8b2afddc5569968a8a91fa5b0 (patch) | |
tree | 75cc5e05a4392ea0292251898f992a15a16b172b /benchmarking/bench_packages.py | |
parent | Initial commit. (diff) | |
download | markdown-it-py-12e8343068b906f8b2afddc5569968a8a91fa5b0.tar.xz markdown-it-py-12e8343068b906f8b2afddc5569968a8a91fa5b0.zip |
Adding upstream version 2.1.0.upstream/2.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'benchmarking/bench_packages.py')
-rw-r--r-- | benchmarking/bench_packages.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/benchmarking/bench_packages.py b/benchmarking/bench_packages.py new file mode 100644 index 0000000..1158750 --- /dev/null +++ b/benchmarking/bench_packages.py @@ -0,0 +1,69 @@ +from pathlib import Path +from shutil import which + +import pytest + + +@pytest.fixture +def spec_text(): + return Path(__file__).parent.joinpath("samples", "spec.md").read_text() + + +@pytest.mark.benchmark(group="packages") +def test_markdown_it_py(benchmark, spec_text): + import markdown_it + + parser = markdown_it.MarkdownIt("commonmark") + benchmark.extra_info["version"] = markdown_it.__version__ + benchmark(parser.render, spec_text) + + +@pytest.mark.benchmark(group="packages") +def test_mistune(benchmark, spec_text): + import mistune + + benchmark.extra_info["version"] = mistune.__version__ + benchmark(mistune.markdown, spec_text) + + +@pytest.mark.benchmark(group="packages") +def test_commonmark_py(benchmark, spec_text): + import commonmark + + benchmark.extra_info["version"] = "0.9.1" + benchmark(commonmark.commonmark, spec_text) + + +@pytest.mark.benchmark(group="packages") +def test_pymarkdown(benchmark, spec_text): + import markdown + + benchmark.extra_info["version"] = markdown.__version__ + benchmark(markdown.markdown, spec_text) + + +@pytest.mark.benchmark(group="packages") +def test_pymarkdown_extra(benchmark, spec_text): + import markdown + + benchmark.extra_info["version"] = markdown.__version__ + benchmark(markdown.markdown, spec_text, extensions=["extra"]) + + +@pytest.mark.benchmark(group="packages") +def test_mistletoe(benchmark, spec_text): + import mistletoe + + benchmark.extra_info["version"] = mistletoe.__version__ + benchmark(mistletoe.markdown, spec_text) + + +@pytest.mark.skipif(which("pandoc") is None, reason="pandoc executable not found") +@pytest.mark.benchmark(group="packages") +def test_panflute(benchmark, spec_text): + import panflute + + benchmark.extra_info["version"] = panflute.__version__ + benchmark( + panflute.convert_text, spec_text, input_format="markdown", output_format="html" + ) |