markdown-it-rust / markdown-it

markdown-it js library rewritten in rust
Other
79 stars 9 forks source link

What does "fast" mean? #2

Closed NeverGivinUp closed 1 year ago

NeverGivinUp commented 1 year ago

The readme states "if you want to get result fast, use pulldown-cmark".

Does "fast" in this context refer to development speed, parsing speed, compile time, another kind of performance measure?

How do these performance measures compare to pulldown-cmark (in orders of magnitude)?

rlidwka commented 1 year ago

It's about parsing speed only. Compile time doesn't matter a lot, and development speed is extremely hard to measure.

You should probably run your own benchmarks, try this command:

$ hyperfine './pulldown-cmark < test.md' './comrak test.md' './markdown-it test.md'

On 5mb markdown file on my machine pulldown-cmark was about ~6 times faster with default options (rough estimate).

Benchmark 1: ./pulldown-cmark < test.md
  Time (mean ± σ):      37.3 ms ±   2.4 ms    [User: 36.1 ms, System: 0.0 ms]
  Range (min … max):    35.0 ms …  45.7 ms    76 runs

Benchmark 2: ./comrak test.md
  Time (mean ± σ):     461.4 ms ±  13.2 ms    [User: 461.0 ms, System: 0.0 ms]
  Range (min … max):   446.5 ms … 491.3 ms    10 runs

Benchmark 3: ./markdown-it test.md
  Time (mean ± σ):     247.6 ms ±  18.2 ms    [User: 247.6 ms, System: 0.0 ms]
  Range (min … max):   238.3 ms … 304.5 ms    12 runs

Summary
  './pulldown-cmark < test.md' ran
    6.65 ± 0.65 times faster than './markdown-it test.md'
   12.39 ± 0.87 times faster than './comrak test.md'
NeverGivinUp commented 1 year ago

Thanks @rlidwka :) about 6x faster for large files is the rough measure that helps understand. I suggest you make that clear in the readme (in case I'm not the only one that wonders). Another interesting measure would be the parsing speed of 10000 small documents of say 5 to 200 words each (which is my use case).