vernak2539 / astro-rehype-relative-markdown-links

Rehype Plugin for Astro that allows for usage of relative links between markdown files
https://www.npmjs.com/package/astro-rehype-relative-markdown-links
12 stars 4 forks source link

perf: cache frontmatter #51

Closed techfg closed 5 months ago

techfg commented 5 months ago

IMPORTANT - This PR contains the fixes in #55 so should be merged after it.

Caches the frontmatter data per file to avoid reading the file every time a link references it.

Very primitive/raw perf analysis at https://stackblitz.com/edit/stackblitz-starters-7np4gm.

  1. Navigate to https://stackblitz.com/edit/stackblitz-starters-7np4gm
  2. In terminal, run node ./index.js

Analysis only considers execution time, does not look at memory consumption, etc. but this should yield some memory consumption benefit in most situations as well.

❯ node ./index.js
cached x 65,687,202 ops/sec ±7.16% (64 runs sampled)
notCached x 8,121 ops/sec ±5.35% (70 runs sampled)
Fastest is cached
vernak2539 commented 5 months ago

Rebased changes from main after two other merges. PR is cleaner! Merging now.