diff --git a/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts b/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts index ad6d7baa1ae..1fe167f384e 100644 --- a/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts +++ b/packages/dds/tree/src/test/tablePerformanceTestUtilities.ts @@ -118,28 +118,19 @@ export function createTableTree({ tableSize, initialCellValue }: TableTreeOption const columns = Array.from({ length: tableSize }, () => new Column({})); table.insertColumns({ index: 0, columns }); - const rows = Array.from( - { length: tableSize }, - () => - new Row({ - cells: {}, - }), - ); - table.insertRows({ index: 0, rows }); - - if (initialCellValue !== undefined) { - for (const row of table.rows) { - for (const column of table.columns) { - table.setCell({ - key: { - column, - row, - }, - cell: initialCellValue, - }); + // Pre populate each row's cells at construction time so the entire dense table is initialized + // by a single `insertRows` op. + const columnIds = table.columns.map((column) => column.id); + const rows = Array.from({ length: tableSize }, () => { + const cells: Record = {}; + if (initialCellValue !== undefined) { + for (const columnId of columnIds) { + cells[columnId] = initialCellValue; } } - } + return new Row({ cells }); + }); + table.insertRows({ index: 0, rows }); // Configure event listeners const cleanUpEventHandler = Tree.on(table, "treeChanged", () => {});