You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not a problem... an efficiency enhancement. We ran typedoc thru the nodeJs profiler to investigate why running typedoc against our system was taking so long.
At 23% was renderElement in lib/utils/jsx.js. We know the large number of interfaces in one d.ts was the cause of this and have opened an enhancement for it. See open issue #2382
At 13.5% was getRelativeUrl in lib/output/component.js. This method converts an absolute path to a relative path and is the target of this enhancement request below.
Suggested Solution
The enhancement we suggest is to use a Map to hold the results of previous conversions and return the held result if the key matches.
/**
* Map to hold previous absolute path to relative path conversions
*/
protected absoluteToRelativePathMap = new Map<string, string>();
/**
* Transform the given absolute path into a relative path.
*
* @param absolute The absolute path to transform.
* @returns A path relative to the document currently processed.
*/
public getRelativeUrl(absolute: string): string {
if (this.urlPrefix.test(absolute)) {
return absolute;
} else {
const key = `${this.location}:${absolute}`;
let path = this.absoluteToRelativePathMap.get(key);
if (path) return path;
path = Path.posix.relative(this.location, absolute) || ".";
this.absoluteToRelativePathMap.set(key, path);
return path;
}
}
After we implemented this locally the getRelativeUrl went from 13.5%(2nd highest @55,925 ticks) of the total time to %0(99th highest @ 25 ticks).
For our project typedoc calls getRelativeUrl a total of 87,530,384 times (yup... that is 87.5 million)... 149,731 of those are unique... which means there are 87,380,653(99.83%) duplicate calls... we currently have 9,342 pages.
Even though a Map get/set are not noops... they use significantly less processing than Path.posix.relative... therefore we make huge savings (~13.5%) on processing with this small change.
Obviously with small projects this is probably not even noticeable. However, the larger the project the bigger the impact.
I just noticed this... wat, that makes me want to kill wbr. Not sure it provides any real value to begin with, it's a carryover from back when the themes were in handlebars.
I'm working (hopefully tomorrow) on having navigation load dynamically, which should drastically reduce the number of calls to getRelativeUrl
Search Terms
getRelativeUrl, enhancement
Problem
Not a problem... an efficiency enhancement. We ran typedoc thru the nodeJs profiler to investigate why running typedoc against our system was taking so long.
Top 6 of the node profiler output:
There were 2 significant areas for us:
Suggested Solution
The enhancement we suggest is to use a Map to hold the results of previous conversions and return the held result if the key matches.
After we implemented this locally the getRelativeUrl went from 13.5%(2nd highest @55,925 ticks) of the total time to %0(99th highest @ 25 ticks).
For our project typedoc calls getRelativeUrl a total of 87,530,384 times (yup... that is 87.5 million)... 149,731 of those are unique... which means there are 87,380,653(99.83%) duplicate calls... we currently have 9,342 pages.
Even though a Map get/set are not noops... they use significantly less processing than Path.posix.relative... therefore we make huge savings (~13.5%) on processing with this small change.
Obviously with small projects this is probably not even noticeable. However, the larger the project the bigger the impact.
Latest profiling top 6 (using change above).
The text was updated successfully, but these errors were encountered: