Skip to content

Commit

Permalink
[IMP] BottomBarStatistics: limit redundant getter calls
Browse files Browse the repository at this point in the history
While we iterate over the cells to check their visibility, we keep
checking the visibility of cells over which we already know that their
col (or row) is hidden.

This revision adds a memoization of limit the calls to the different
getters involved by memoizing them as well as skips the visit of cells
within columns that are hidden.

Benchmark
---------

In Firefox with the largeDataSet of 260k cells, averaged over 10 runs:

Skipping entire hidden columns

         _computeStatisticFnResult
-----------------------------------
before:           95.8 ms
after:            79   ms

Skipping hidden columns + memoization

         _computeStatisticFnResult
-----------------------------------
before:           95.8 ms
after:            72.4 ms

Task: 3827324
  • Loading branch information
rrahir committed Apr 8, 2024
1 parent 82afe4f commit a7dc365
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,17 @@ export class AggregateStatisticsStore extends SpreadsheetStore {
const sheetId = getters.getActiveSheetId();
const cells = new Set<EvaluatedCell>();

const isColHidden = memoize((col: number) => getters.isColHidden(sheetId, col));
const isRowHidden = memoize((row: number) => getters.isRowHidden(sheetId, row));
const zones = getters.getSelectedZones();
for (const zone of zones) {
for (let col = zone.left; col <= zone.right; col++) {
if (isColHidden(col)) {
continue; // Skip hidden columns
}
for (let row = zone.top; row <= zone.bottom; row++) {
if (getters.isRowHidden(sheetId, row) || getters.isColHidden(sheetId, col)) {
continue; // Skip hidden cells
if (isRowHidden(row)) {
continue; // Skip hidden rows
}

const evaluatedCell = getters.getEvaluatedCell({ sheetId, col, row });
Expand Down

0 comments on commit a7dc365

Please sign in to comment.