Skip to content

DatasetHelper enumerator traversal, any chance to improve performance? #3

@georges-hatem

Description

@georges-hatem

Hello,

Given a query dataset of 1.4M records, 6 fields, I have timed the query traversal using different approaches to see how much the RTTI readability would cost in terms of performance.

FieldByName within the loop: 11,121 ms

query.First;
while not query.Eof do begin
  mystringvar := query.FieldByName ('A').AsString + query.FieldByName ('B').AsString + ...
  query.next;
end

FieldByName before the loop: 9,590 ms

query.First;
fieldA := query.FieldByName ('A');
fieldB := query.FieldByName ('B');
while not query.Eof do begin
  mystringvar := fieldA.AsString + fieldB.AsString + ...
  query.next;
end

Using CmonLib's DatasetHelper: 14,356 ms

for myRec in vQuery.Records<TMyRec> do begin
  mystringvar := myRec.A + myRec.B + ...
end;

Do you reckon there is a way to improve the performance of the CmonLib's approach so as to maintain the readability but with a lesser performance penalty?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions