Skip to content

Commit

Permalink
Revert cache added in #2386
Browse files Browse the repository at this point in the history
The router implementation used by TypeDoc now indicates that in a 22.5 second run
rendering all of `@types/node`, 65ms is spent getting URLs. The extra complexity
in attempting to cache the result of this frankly isn't worth it.

HTML rendering took 16.8 seconds, of which 13.6 seconds was just doing syntax
highlighting. Shiki is the most obvious place to spend time investigating performance
improvements at this point.
  • Loading branch information
Gerrit0 committed Dec 15, 2024
1 parent 0912452 commit 5eb27da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
4 changes: 0 additions & 4 deletions src/lib/output/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ export class DefaultRouter implements Router {
protected fullUrls = new Map<Reflection, string>();
protected anchors = new Map<Reflection, string>();

// #2386, we get URLs a lot, saving a cache helps.
// ... but does it actually? Retest.
// private fullToRelativeUrlCache = new Map<string, string>();

@Option("sluggerConfiguration")
private accessor sluggerConfiguration!: TypeDocOptionMap["sluggerConfiguration"];

Expand Down
26 changes: 10 additions & 16 deletions src/lib/utils/perf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,14 @@ export function measure<T>(cb: () => T): T {
process.on("exit", () => {
if (!benchmarks.length) return;

const width = benchmarks.reduce((a, b) => Math.max(a, b.name.length), 11);
console.log("=".repeat(width + 35));
console.log(
`${"Benchmarked".padEnd(width)} | Calls | Time (ms) | Average (ms)`,
);
console.log("=".repeat(width + 35));

for (const { name, calls, time } of benchmarks) {
console.log(
`${name.padEnd(width)} | ${calls.toString().padEnd(5)} | ${time
.toFixed(2)
.padEnd(9)} | ${(time / calls).toFixed(2)}`,
);
}

console.log("=".repeat(width + 35));
const table = benchmarks.map((b) => {
return {
Benchmarked: b.name,
Calls: b.calls,
"Time (ms)": Math.round(b.time * 100) / 100,
"Average (ms)": Math.round((b.time / b.calls) * 100) / 100,
};
});

console.table(table);
});

0 comments on commit 5eb27da

Please sign in to comment.