Skip to content

Commit

Permalink
[FIX] tests: Bypass useless drawGrid
Browse files Browse the repository at this point in the history
A non negligeable part of the rendering process consists of computations before
drawing on the canvas. At runtime, drawgrid takes around 99% of the rendering
time with in details:

Model.drawgrid : 8.7 ms
getGridBoxes: 3.53 ms
GetHeaderOffset: 1.09 ms
getVisibleRect: 0.37 ms
getSheetViewVisibleCols: 0.13ms

Which sums to (3.53+1.09+0.37+0.13)/8.7  * .99 = 58.2% of the rendering time.

In the tests, we completely mock the canvas to not draw anything. Based on that,
we are left with the computations which are not used anyway.

Tests `npm run test -- --maxWorkers=2 components`

before: 1108 tests > 108 seconds

after:  1108 tests > 85.77 seconds

==> 20.5 % improvement

closes #2292

Task: 3254822
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
  • Loading branch information
rrahir committed Mar 30, 2023
1 parent 3899337 commit b0744a4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tests/test_helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export async function mountComponent<Props extends { [key: string]: any }>(
env: SpreadsheetChildEnv;
}> {
const model = optionalArgs.model || optionalArgs?.env?.model || new Model();
model.drawGrid = () => {};
const env = makeTestEnv({ ...optionalArgs.env, model: model });
const props = optionalArgs.props || ({} as Props);
const app = new App(component, { props, env, test: true });
Expand Down

0 comments on commit b0744a4

Please sign in to comment.