diff options
27 files changed, 458 insertions, 1 deletions
@@ -9,6 +9,7 @@ SITE=_site SPECVERSION=$(shell perl -ne 'print $$1 if /^version: *([0-9.]+)/' $(SPEC)) FUZZCHARS?=2000000 # for fuzztest BENCHDIR=bench +BENCHSAMPLES=$(wildcard $(BENCHDIR)/samples/*.md) BENCHFILE=$(BENCHDIR)/benchinput.md ALLTESTS=alltests.md NUMRUNS?=10 @@ -21,7 +22,7 @@ CLANG_CHECK?=clang-check CLANG_FORMAT=clang-format -style llvm -sort-includes=0 -i AFL_PATH?=/usr/local/bin -.PHONY: all cmake_build leakcheck clean fuzztest test debug ubsan asan mingw archive bench format update-spec afl clang-check +.PHONY: all cmake_build leakcheck clean fuzztest test debug ubsan asan mingw archive newbench bench format update-spec afl clang-check all: cmake_build man/man3/cmark.3 @@ -166,6 +167,17 @@ bench: $(BENCHFILE) done \ } 2>&1 | grep 'real' | awk '{print $$2}' | python3 'bench/stats.py' +newbench: + for f in $(BENCHSAMPLES) ; do \ + printf "%26s " `basename $$f` ; \ + { for x in `seq 1 $(NUMRUNS)` ; do \ + /usr/bin/env time -p $(PROG) </dev/null >/dev/null ; \ + for x in `seq 1 200` ; do cat $$f ; done | \ + /usr/bin/env time -p $(PROG) > /dev/null; \ + done \ + } 2>&1 | grep 'real' | awk '{print $$2}' | \ + python3 'bench/stats.py'; done + format: $(CLANG_FORMAT) src/*.c src/*.h api_test/*.c api_test/*.h @@ -100,6 +100,10 @@ To run a benchmark: make bench +For more detailed benchmarks: + + make newbench + To run a test for memory leaks using `valgrind`: make leakcheck diff --git a/bench/samples/block-bq-flat.md b/bench/samples/block-bq-flat.md new file mode 100644 index 0000000..33e382a --- /dev/null +++ b/bench/samples/block-bq-flat.md @@ -0,0 +1,16 @@ +> the simple example of a blockquote +> the simple example of a blockquote +> the simple example of a blockquote +> the simple example of a blockquote +... continuation +... continuation +... continuation +... continuation + +empty blockquote: + +> +> +> +> + diff --git a/bench/samples/block-bq-nested.md b/bench/samples/block-bq-nested.md new file mode 100644 index 0000000..7ddcffa --- /dev/null +++ b/bench/samples/block-bq-nested.md @@ -0,0 +1,13 @@ +>>>>>> deeply nested blockquote +>>>>> deeply nested blockquote +>>>> deeply nested blockquote +>>> deeply nested blockquote +>> deeply nested blockquote +> deeply nested blockquote + +> deeply nested blockquote +>> deeply nested blockquote +>>> deeply nested blockquote +>>>> deeply nested blockquote +>>>>> deeply nested blockquote +>>>>>> deeply nested blockquote diff --git a/bench/samples/block-code.md b/bench/samples/block-code.md new file mode 100644 index 0000000..2b1554f --- /dev/null +++ b/bench/samples/block-code.md @@ -0,0 +1,11 @@ + + an + example + + of + + + + a code + block + diff --git a/bench/samples/block-fences.md b/bench/samples/block-fences.md new file mode 100644 index 0000000..5fe8b3c --- /dev/null +++ b/bench/samples/block-fences.md @@ -0,0 +1,14 @@ + +``````````text +an +example +``` +of + + +a fenced +``` +code +block +`````````` + diff --git a/bench/samples/block-heading.md b/bench/samples/block-heading.md new file mode 100644 index 0000000..fd98558 --- /dev/null +++ b/bench/samples/block-heading.md @@ -0,0 +1,9 @@ +# heading +### heading +##### heading + +# heading # +### heading ### +##### heading \#\#\#\#\###### + +############ not a heading diff --git a/bench/samples/block-hr.md b/bench/samples/block-hr.md new file mode 100644 index 0000000..e1bad6f --- /dev/null +++ b/bench/samples/block-hr.md @@ -0,0 +1,10 @@ + + * * * * * + + - - - - - + + ________ + + + ************************* text + diff --git a/bench/samples/block-html.md b/bench/samples/block-html.md new file mode 100644 index 0000000..ff7f8fa --- /dev/null +++ b/bench/samples/block-html.md @@ -0,0 +1,32 @@ +<div class="this is an html block"> + +blah blah + +</div> + +<table> + <tr> + <td> + **test** + </td> + </tr> +</table> + +<table> + + <tr> + + <td> + + test + + </td> + + </tr> + +</table> + +<![CDATA[ + [[[[[[[[[[[... *cdata section - this should not be parsed* ...]]]]]]]]]]] +]]> + diff --git a/bench/samples/block-lheading.md b/bench/samples/block-lheading.md new file mode 100644 index 0000000..e5c0d99 --- /dev/null +++ b/bench/samples/block-lheading.md @@ -0,0 +1,8 @@ +heading +--- + +heading +=================================== + +not a heading +----------------------------------- text diff --git a/bench/samples/block-list-flat.md b/bench/samples/block-list-flat.md new file mode 100644 index 0000000..14149db --- /dev/null +++ b/bench/samples/block-list-flat.md @@ -0,0 +1,67 @@ + - tidy + - bullet + - list + + + - loose + + - bullet + + - list + + + 0. ordered + 1. list + 2. example + + + - + - + - + - + + + 1. + 2. + 3. + + + - an example +of a list item + with a continuation + + this part is inside the list + + this part is just a paragraph + + + 1. test + - test + 1. test + - test + + +111111111111111111111111111111111111111111. is this a valid bullet? + + - _________________________ + + - this + - is + + a + + long + - loose + - list + + - with + - some + + tidy + + - list + - items + - in + + - between + - _________________________ diff --git a/bench/samples/block-list-nested.md b/bench/samples/block-list-nested.md new file mode 100644 index 0000000..d30aed3 --- /dev/null +++ b/bench/samples/block-list-nested.md @@ -0,0 +1,36 @@ + + - this + - is + - a + - deeply + - nested + - bullet + - list + + + 1. this + 2. is + 3. a + 4. deeply + 5. nested + 6. unordered + 7. list + + + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + + + - - - - - - - - - deeply-nested one-element item + diff --git a/bench/samples/block-ref-flat.md b/bench/samples/block-ref-flat.md new file mode 100644 index 0000000..c83dccb --- /dev/null +++ b/bench/samples/block-ref-flat.md @@ -0,0 +1,15 @@ +[1] [2] [3] [1] [2] [3] + +[looooooooooooooooooooooooooooooooooooooooooooooooooong label] + + [1]: <http://something.example.com/foo/bar> + [2]: http://something.example.com/foo/bar 'test' + [3]: + http://foo/bar + [ looooooooooooooooooooooooooooooooooooooooooooooooooong label ]: + 111 + 'test' + [[[[[[[[[[[[[[[[[[[[ this should not slow down anything ]]]]]]]]]]]]]]]]]]]]: q + (as long as it is not referenced anywhere) + + [[[[[[[[[[[[[[[[[[[[]: this is not a valid reference diff --git a/bench/samples/block-ref-nested.md b/bench/samples/block-ref-nested.md new file mode 100644 index 0000000..1e10a8c --- /dev/null +++ b/bench/samples/block-ref-nested.md @@ -0,0 +1,17 @@ +[[[[[[[foo]]]]]]] + +[[[[[[[foo]]]]]]]: bar +[[[[[[foo]]]]]]: bar +[[[[[foo]]]]]: bar +[[[[foo]]]]: bar +[[[foo]]]: bar +[[foo]]: bar +[foo]: bar + +[*[*[*[*[foo]*]*]*]*] + +[*[*[*[*[foo]*]*]*]*]: bar +[*[*[*[foo]*]*]*]: bar +[*[*[foo]*]*]: bar +[*[foo]*]: bar +[foo]: bar diff --git a/bench/samples/inline-autolink.md b/bench/samples/inline-autolink.md new file mode 100644 index 0000000..0f71482 --- /dev/null +++ b/bench/samples/inline-autolink.md @@ -0,0 +1,14 @@ +closed (valid) autolinks: + + <ftp://1.2.3.4:21/path/foo> + <http://foo.bar.baz?q=hello&id=22&boolean> + <http://veeeeeeeeeeeeeeeeeeery.loooooooooooooooooooooooooooooooong.autolink/> + <teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeest@gmail.com> + +these are not autolinks: + + <ftp://1.2.3.4:21/path/foo + <http://foo.bar.baz?q=hello&id=22&boolean + <http://veeeeeeeeeeeeeeeeeeery.loooooooooooooooooooooooooooooooong.autolink + <teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeest@gmail.com + < http://foo.bar.baz?q=hello&id=22&boolean > diff --git a/bench/samples/inline-backticks.md b/bench/samples/inline-backticks.md new file mode 100644 index 0000000..a6ec6e1 --- /dev/null +++ b/bench/samples/inline-backticks.md @@ -0,0 +1,3 @@ +`lots`of`backticks` + +``i``wonder``how``this``will``be``parsed`` diff --git a/bench/samples/inline-em-flat.md b/bench/samples/inline-em-flat.md new file mode 100644 index 0000000..b7668a5 --- /dev/null +++ b/bench/samples/inline-em-flat.md @@ -0,0 +1,5 @@ +*this* *is* *your* *basic* *boring* *emphasis* + +_this_ _is_ _your_ _basic_ _boring_ _emphasis_ + +**this** **is** **your** **basic** **boring** **emphasis** diff --git a/bench/samples/inline-em-nested.md b/bench/samples/inline-em-nested.md new file mode 100644 index 0000000..6bb0a0d --- /dev/null +++ b/bench/samples/inline-em-nested.md @@ -0,0 +1,5 @@ +*this *is *a *bunch* of* nested* emphases* + +__this __is __a __bunch__ of__ nested__ emphases__ + +***this ***is ***a ***bunch*** of*** nested*** emphases*** diff --git a/bench/samples/inline-em-worst.md b/bench/samples/inline-em-worst.md new file mode 100644 index 0000000..b6d21da --- /dev/null +++ b/bench/samples/inline-em-worst.md @@ -0,0 +1,5 @@ +*this *is *a *worst *case *for *em *backtracking + +__this __is __a __worst __case __for __em __backtracking + +***this ***is ***a ***worst ***case ***for ***em ***backtracking diff --git a/bench/samples/inline-entity.md b/bench/samples/inline-entity.md new file mode 100644 index 0000000..da095ed --- /dev/null +++ b/bench/samples/inline-entity.md @@ -0,0 +1,11 @@ +entities: + + & © Æ Ď ¾ ℋ ⅆ ∲ + +# Ӓ Ϡ � + +non-entities: + +&18900987654321234567890; &1234567890098765432123456789009876543212345678987654; + +&qwertyuioppoiuytrewqwer; &oiuytrewqwertyuioiuytrewqwertyuioytrewqwertyuiiuytri; diff --git a/bench/samples/inline-escape.md b/bench/samples/inline-escape.md new file mode 100644 index 0000000..4e1bb39 --- /dev/null +++ b/bench/samples/inline-escape.md @@ -0,0 +1,15 @@ + +\t\e\s\t\i\n\g \e\s\c\a\p\e \s\e\q\u\e\n\c\e\s + +\!\\\"\#\$\%\&\'\(\)\*\+\,\.\/\:\;\<\=\>\? + +\@ \[ \] \^ \_ \` \{ \| \} \~ \- \' + +\ +\\ +\\\ +\\\\ +\\\\\ + +\<this\> \<is\> \<not\> \<html\> + diff --git a/bench/samples/inline-html.md b/bench/samples/inline-html.md new file mode 100644 index 0000000..f6e6341 --- /dev/null +++ b/bench/samples/inline-html.md @@ -0,0 +1,44 @@ +Taking commonmark tests from the spec for benchmarking here: + +<a><bab><c2c> + +<a/><b2/> + +<a /><b2 +data="foo" > + +<a foo="bar" bam = 'baz <em>"</em>' +_boolean zoop:33=zoop:33 /> + +<33> <__> + +<a h*#ref="hi"> + +<a href="hi'> <a href=hi'> + +< a>< +foo><bar/ > + +<a href='bar'title=title> + +</a> +</foo > + +</a href="foo"> + +foo <!-- this is a +comment - with hyphen --> + +foo <!-- not a comment -- two hyphens --> + +foo <?php echo $a; ?> + +foo <!ELEMENT br EMPTY> + +foo <![CDATA[>&<]]> + +<a href="ö"> + +<a href="\*"> + +<a href="\""> diff --git a/bench/samples/inline-links-flat.md b/bench/samples/inline-links-flat.md new file mode 100644 index 0000000..5117db8 --- /dev/null +++ b/bench/samples/inline-links-flat.md @@ -0,0 +1,23 @@ +Valid links: + + [this is a link]() + [this is a link](<http://something.example.com/foo/bar>) + [this is a link](http://something.example.com/foo/bar 'test') + ![this is an image]() + ![this is an image](<http://something.example.com/foo/bar>) + ![this is an image](http://something.example.com/foo/bar 'test') + + [escape test](<\>\>\>\>\>\>\>\>\>\>\>\>\>\>> '\'\'\'\'\'\'\'\'\'\'\'\'\'\'') + [escape test \]\]\]\]\]\]\]\]\]\]\]\]\]\]\]\]](\)\)\)\)\)\)\)\)\)\)\)\)\)\)) + +Invalid links: + + [this is not a link + + [this is not a link]( + + [this is not a link](http://something.example.com/foo/bar 'test' + + [this is not a link]((((((((((((((((((((((((((((((((((((((((((((((( + + [this is not a link]((((((((((()))))))))) (((((((((())))))))))) diff --git a/bench/samples/inline-links-nested.md b/bench/samples/inline-links-nested.md new file mode 100644 index 0000000..4e7dc85 --- /dev/null +++ b/bench/samples/inline-links-nested.md @@ -0,0 +1,13 @@ +Valid links: + +[[[[[[[[](test)](test)](test)](test)](test)](test)](test)] + +[ [[[[[[[[[[[[[[[[[[ [](test) ]]]]]]]]]]]]]]]]]] ](test) + +Invalid links: + +[[[[[[[[[ + +[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ + +![![![![![![![![![![![![![![![![![![![![![![![![![![![![![![![![![![![![![![ diff --git a/bench/samples/inline-newlines.md b/bench/samples/inline-newlines.md new file mode 100644 index 0000000..068a807 --- /dev/null +++ b/bench/samples/inline-newlines.md @@ -0,0 +1,24 @@ + +this\ +should\ +be\ +separated\ +by\ +newlines + +this +should +be +separated +by +newlines +too + +this +should +not +be +separated +by +newlines + diff --git a/bench/samples/lorem1.md b/bench/samples/lorem1.md new file mode 100644 index 0000000..eccb898 --- /dev/null +++ b/bench/samples/lorem1.md @@ -0,0 +1,13 @@ +Lorem ipsum dolor sit amet, __consectetur__ adipiscing elit. Cras imperdiet nec erat ac condimentum. Nulla vel rutrum ligula. Sed hendrerit interdum orci a posuere. Vivamus ut velit aliquet, mollis purus eget, iaculis nisl. Proin posuere malesuada ante. Proin auctor orci eros, ac molestie lorem dictum nec. Vestibulum sit amet erat est. Morbi luctus sed elit ac luctus. Proin blandit, enim vitae egestas posuere, neque elit ultricies dui, vel mattis nibh enim ac lorem. Maecenas molestie nisl sit amet velit dictum lobortis. Aliquam erat volutpat. + +Vivamus sagittis, diam in [vehicula](https://github.com/markdown-it/markdown-it) lobortis, sapien arcu mattis erat, vel aliquet sem urna et risus. Ut feugiat sapien vitae mi elementum laoreet. Suspendisse potenti. Aliquam erat nisl, aliquam pretium libero aliquet, sagittis eleifend nunc. In hac habitasse platea dictumst. Integer turpis augue, tincidunt dignissim mauris id, rhoncus dapibus purus. Maecenas et enim odio. Nullam massa metus, varius quis vehicula sed, pharetra mollis erat. In quis viverra velit. Vivamus placerat, est nec hendrerit varius, enim dui hendrerit magna, ut pulvinar nibh lorem vel lacus. Mauris a orci iaculis, hendrerit eros sed, gravida leo. In dictum mauris vel augue varius, ac ullamcorper nisl ornare. In eu posuere velit, ac fermentum arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nullam sed malesuada leo, at interdum elit. + +Nullam ut tincidunt nunc. [Pellentesque][1] metus lacus, commodo eget justo ut, rutrum varius nunc. Sed non rhoncus risus. Morbi sodales gravida pulvinar. Duis malesuada, odio volutpat elementum vulputate, massa magna scelerisque ante, et accumsan tellus nunc in sem. Donec mattis arcu et velit aliquet, non sagittis justo vestibulum. Suspendisse volutpat felis lectus, nec consequat ipsum mattis id. Donec dapibus vehicula facilisis. In tincidunt mi nisi, nec faucibus tortor euismod nec. Suspendisse ante ligula, aliquet vitae libero eu, vulputate dapibus libero. Sed bibendum, sapien at posuere interdum, libero est sollicitudin magna, ac gravida tellus purus eu ipsum. Proin ut quam arcu. + +Suspendisse potenti. Donec ante velit, ornare at augue quis, tristique laoreet sem. Etiam in ipsum elit. Nullam cursus dolor sit amet nulla feugiat tristique. Phasellus ac tellus tincidunt, imperdiet purus eget, ullamcorper ipsum. Cras eu tincidunt sem. Nullam sed dapibus magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id venenatis tortor. In consectetur sollicitudin pharetra. Etiam convallis nisi nunc, et aliquam turpis viverra sit amet. Maecenas faucibus sodales tortor. Suspendisse lobortis mi eu leo viverra volutpat. Pellentesque velit ante, vehicula sodales congue ut, elementum a urna. Cras tempor, ipsum eget luctus rhoncus, arcu ligula fermentum urna, vulputate pharetra enim enim non libero. + +Proin diam quam, elementum in eleifend id, elementum et metus. Cras in justo consequat justo semper ultrices. Sed dignissim lectus a ante mollis, nec vulputate ante molestie. Proin in porta nunc. Etiam pulvinar turpis sed velit porttitor, vel adipiscing velit fringilla. Cras ac tellus vitae purus pharetra tincidunt. Sed cursus aliquet aliquet. Cras eleifend commodo malesuada. In turpis turpis, ullamcorper ut tincidunt a, ullamcorper a nunc. Etiam luctus tellus ac dapibus gravida. Ut nec lacus laoreet neque ullamcorper volutpat. + +Nunc et leo erat. Aenean mattis ultrices lorem, eget adipiscing dolor ultricies eu. In hac habitasse platea dictumst. Vivamus cursus feugiat sapien quis aliquam. Mauris quam libero, porta vel volutpat ut, blandit a purus. Vivamus vestibulum dui vel tortor molestie, sit amet feugiat sem commodo. Nulla facilisi. Sed molestie arcu eget tellus vestibulum tristique. + +[1]: https://github.com/markdown-it diff --git a/bench/samples/rawtabs.md b/bench/samples/rawtabs.md new file mode 100644 index 0000000..dc989ea --- /dev/null +++ b/bench/samples/rawtabs.md @@ -0,0 +1,18 @@ + +this is a test for tab expansion, be careful not to replace them with spaces + +1 4444 +22 333 +333 22 +4444 1 + + + tab-indented line + space-indented line + tab-indented line + + +a lot of spaces in between here + +a lot of tabs in between here + |