Skip to content
Permalink
Browse files

Performance: use first 1000 rows only for calculating the CSV export …

…size, and interpolate the rest. Closes #804
  • Loading branch information
ansgarbecker committed Jan 21, 2020
1 parent 4497cb2 commit feeb17e7d42593276c37f67b7b753836e2024e28
Showing with 9 additions and 1 deletion.
  1. +9 −1 source/exportgrid.pas
@@ -413,7 +413,7 @@ procedure TfrmExportGrid.CalcSize(Sender: TObject);
Node: PVirtualNode;
Col, ExcludeCol: TColumnIndex;
RowNum: PInt64;
SelectionSize, AllSize: Int64;
SelectionSize, AllSize, RowsCalculated: Int64;
begin
GridData := Mainform.GridResult(Grid);
AllSize := 0;
@@ -424,6 +424,7 @@ procedure TfrmExportGrid.CalcSize(Sender: TObject);
ExcludeCol := GridData.AutoIncrementColumn;

Node := GetNextNode(Grid, nil, False);
RowsCalculated := 0;
while Assigned(Node) do begin
RowNum := Grid.GetNodeData(Node);
GridData.RecNo := RowNum^;
@@ -436,8 +437,15 @@ procedure TfrmExportGrid.CalcSize(Sender: TObject);
end;
Col := Grid.Header.Columns.GetNextVisibleColumn(Col);
end;
// Performance: use first rows only, and interpolate the rest, see issue #804
Inc(RowsCalculated);
if RowsCalculated >= 1000 then
Break;
Node := GetNextNode(Grid, Node, False);
end;
if GridData.RecordCount > RowsCalculated then begin
AllSize := Round(AllSize / RowsCalculated * GridData.RecordCount);
end;
grpSelection.Items[0] := f_('Selection (%s rows, %s)', [FormatNumber(Grid.SelectedCount), FormatByteNumber(SelectionSize)]);
grpSelection.Items[1] := f_('Complete (%s rows, %s)', [FormatNumber(Grid.RootNodeCount), FormatByteNumber(AllSize)]);
end;

0 comments on commit feeb17e

Please sign in to comment.
You can’t perform that action at this time.