kkga / ter

A tiny wiki-style site generator with Zettelkasten flavor.
https://ter.kkga.me
MIT License
96 stars 6 forks source link

Add getChildPages optimization #39

Closed healeycodes closed 1 year ago

healeycodes commented 1 year ago

👋 @kkga

This getChildPages optimization speeds up the 10k markdown file benchmark by 20-30sec on my M1 Pro.

I traced the benchmark and saw we were spending 60sec in this function:

Screenshot 2023-04-19 at 20 58 59

We call getChildPages twice per page and end up doing duplicate work (looping the other pages).

This PR roughly halves the amount of time we spend in this function.

There are no performance benefits for small builds (e.g. docs).

As always, no pressure to merge this – just sharing for interest :)

Benchmark used

git clone https://github.com/Zettelkasten-Method/10000-markdown-files
time deno run -A --unstable main.ts --input 10000-markdown-files
vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 19, 2023 8:05pm
kkga commented 1 year ago

Looks great! As always, thanks for your contribution :D