Coming from here
Problem
Constantly copying all reports in the getOrderedReportIDs function is resource-intensive. We're doing this just to add a single property, and we are using only 2 copied properties. This process significantly increases the function's runtime.
report = {
...report,
displayName: ReportUtils.getReportName(report),
};
Solution
Avoid copying the entire report object. Instead, create a minimized report version that only includes the necessary properties. This approach is safe as these data are used solely for sorting.
type MiniReport = {
reportID?: string;
displayName: string;
lastVisibleActionCreated?: string;
};
// ...
const miniReport: MiniReport = {
reportID: report?.reportID,
displayName: ReportUtils.getReportName(report),
lastVisibleActionCreated: report?.lastVisibleActionCreated,
};
On my heavy account, I've tested it, and here are the results:
- getOrderedReportIDs function call time: 36% improvement in performance, reduced from 185ms (SD 3ms) → 118ms (SD 8ms), n = 10, measured in the code,
- ReportIDsContextProvider render time: 28% improvement in performance, reduced from 233ms (SD 4ms) → 168ms (SD 2ms), n = 3, measured using a profiler,
A POC with performance measurements is available here. Please let me know if you have any questions.
Issue Owner
Current Issue Owner: @
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~01facc6fcf70a639b9
- Upwork Job ID: 1805325257306582163
- Last Price Increase: 2024-06-24
Issue Owner
Current Issue Owner: @joekaufmanexpensify
Coming from here
Problem
Constantly copying all reports in the
getOrderedReportIDsfunction is resource-intensive. We're doing this just to add a single property, and we are using only 2 copied properties. This process significantly increases the function's runtime.Solution
Avoid copying the entire report object. Instead, create a minimized report version that only includes the necessary properties. This approach is safe as these data are used solely for sorting.
On my heavy account, I've tested it, and here are the results:
A POC with performance measurements is available here. Please let me know if you have any questions.
Issue Owner
Current Issue Owner: @Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @joekaufmanexpensify