Hacker News new | ask | show | jobs
by JasonSage 727 days ago
> Fast, it takes less than 200ms to convert a ~1.4MB Wikipedia page on an i5 7th gen CPU

Okay, maybe I’m way off base here, but is this fast? 1.4MB of Wikipedia page is, what, 20k lines? This doesn’t sound like fast Rust to me.

I would guess that the amount of HTML parsing that’s happening is way more than is actually needed to render markdown.

3 comments

Author here, I'm working on making it faster.

Currently, for the test page https://github.com/letmutex/htmd/blob/main/examples/page-to-..., the debug build is slower than turndown.js (~750ms vs ~670ms on my machine), the release build brings that down to ~170ms. It can definitely be faster, at least the debug build shouldn't be slower than turndown.js.

I haven't checked which parts can be improved, so I'm not sure how much time we can save after optimization.

I'm guessing it's fast compared to the javascript version they ported to rust?
The slow part here is going to be HTML handling.

The comparator - turndown.js - is built on top of domino.js, a mature HTML lib built as a more performance-focused version of Mozilla's DOMJS (an already mature project in itself), so even as slow as NodeJS itself may be, you're running up against some pretty well-crafted libraries in an ecosystem with a long lineage of HTML handling.