Skip to content

Commit b559e56

Browse files
authored
Merge branch 'master' into sync-12.2.0
2 parents f09e8b8 + d357240 commit b559e56

File tree

5 files changed

+50
-17
lines changed

5 files changed

+50
-17
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ exclude .circleci
1414
exclude .circleci/config.yml
1515
exclude codecov.yml
1616
exclude .mypy.ini
17+
exclude profiler.py
1718

1819
include LICENSE
1920
include LICENSE.markdown-it

docs/other.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,29 @@ So, if you decide to use plugins that add extended class syntax or autogeneratin
3838

3939
# Performance
4040

41-
markdown-it-py is the fastest _**CommonMark compliant**_ parser written in python!
42-
4341
You can view our continuous integration benchmarking analysis at: <https://executablebooks.github.io/markdown-it-py/dev/bench/>,
4442
or you can run it for yourself within the repository:
4543

4644
```console
4745
$ tox -e py38-bench-packages -- --benchmark-columns mean,stddev
4846

49-
Name (time in ms) Mean StdDev
50-
-----------------------------------------------------------------
51-
test_mistune 82.0024 (1.0) 10.7779 (1.61)
52-
test_markdown_it_py 190.9571 (2.33) 6.6946 (1.0)
53-
test_mistletoe 247.1633 (3.01) 16.3956 (2.45)
54-
test_commonmark_py 482.6411 (5.89) 67.8219 (10.13)
55-
test_panflute 1,043.0018 (12.72) 229.1034 (34.22)
56-
test_pymarkdown 964.6831 (11.76) 77.2787 (11.54)
57-
test_pymarkdown_extra 1,051.8680 (12.83) 32.2971 (4.82)
58-
-----------------------------------------------------------------
47+
Name (time in ms) Mean StdDev
48+
---------------------------------------------------------------
49+
test_mistune 70.3272 (1.0) 0.7978 (1.0)
50+
test_mistletoe 116.0919 (1.65) 6.2870 (7.88)
51+
test_markdown_it_py 152.9022 (2.17) 4.2988 (5.39)
52+
test_commonmark_py 326.9506 (4.65) 15.8084 (19.81)
53+
test_pymarkdown 368.2712 (5.24) 7.5906 (9.51)
54+
test_pymarkdown_extra 640.4913 (9.11) 15.1769 (19.02)
55+
test_panflute 678.3547 (9.65) 9.4622 (11.86)
56+
---------------------------------------------------------------
5957
```
6058

6159
As you can see, `markdown-it-py` doesn't pay with speed for it's flexibility.
6260

6361
```{note}
6462
`mistune` is not CommonMark compliant, which is what allows for its
6563
faster parsing, at the expense of issues, for example, with nested inline parsing.
66-
See [mistletoes's explanation](https://github.com/miyuchina/mistletoe#performance)
64+
See [mistletoes's explanation](https://github.com/miyuchina/mistletoe/blob/master/performance.md)
6765
for further details.
6866
```

profiler.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""A script for profiling.
2+
3+
To generate and read results:
4+
- `tox -e profile`
5+
- `firefox .tox/prof/output.svg`
6+
"""
7+
from pathlib import Path
8+
9+
from markdown_it import MarkdownIt
10+
11+
commonmark_spec = (
12+
(Path(__file__).parent / "tests" / "test_cmark_spec" / "spec.md")
13+
.read_bytes()
14+
.decode()
15+
)
16+
17+
# Run this a few times to emphasize over imports and other overhead above
18+
for _ in range(10):
19+
MarkdownIt().render(commonmark_spec)

setup.cfg

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ code_style =
4646
pre-commit==2.6
4747
compare =
4848
commonmark~=0.9.1
49-
markdown~=3.2.2
50-
mistletoe-ebp~=0.10.0
51-
mistune~=0.8.4
52-
panflute~=1.12
49+
markdown~=3.3.6
50+
mistletoe~=0.8.1
51+
mistune~=2.0.2
52+
panflute~=2.1.3
5353
linkify =
5454
linkify-it-py~=1.0
5555
plugins =
@@ -70,6 +70,8 @@ benchmarking =
7070
psutil
7171
pytest
7272
pytest-benchmark~=3.2
73+
profiling =
74+
gprof2dot
7375

7476
[options.packages.find]
7577
exclude =

tox.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,16 @@ setenv =
4343
commands =
4444
clean: rm -rf docs/_build
4545
sphinx-build -nW --keep-going -b {posargs:html} docs/ docs/_build/{posargs:html}
46+
47+
[testenv:profile]
48+
description = run profiler (use e.g. `firefox .tox/prof/output.svg` to open)
49+
extras = profiling
50+
allowlist_externals =
51+
mkdir
52+
dot
53+
commands =
54+
mkdir -p "{toxworkdir}/prof"
55+
python -m cProfile -o "{toxworkdir}/prof/output.pstats" profiler.py
56+
gprof2dot -f pstats -o "{toxworkdir}/prof/output.dot" "{toxworkdir}/prof/output.pstats"
57+
dot -Tsvg -o "{toxworkdir}/prof/output.svg" "{toxworkdir}/prof/output.dot"
58+
python -c 'import pathlib; print("profiler svg output under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "prof" / "output.svg"))'

0 commit comments

Comments
 (0)