TAChart: simple improvement for data sources
Original Reporter info from Mantis: Marcin Wiazowski
-
Reporter name:
Original Reporter info from Mantis: Marcin Wiazowski
- Reporter name:
Description:
I'm attaching a patch, that makes adding data to a source about 15% faster in some cases, just for free.
The attached test application creates a new TListChartSource object, and then measures execution time of the following sequence:
List.BeginUpdate;
try
for I := 1 to 2000000 do
List.Add(I,I);
finally
List.EndUpdate;
end;
List.Extent;
The problem is that, initially, the List object has its caches (in particular extent caches) valid. Because caches are valid, each Add() call checks, if - after adding new data - caches are still coherent with the data; this consumes time.
But, at the end, an EndUpdate() call is made, which invalidates all the caches unconditionally... This is required, because application is allowed to modify data directly between BeginUpdate() and EndUpdate() calls. But this also means, that all the efforts, made by Add() calls to keep caches coherent, are just wasted...
The solution is quite simple: caches should be invalidated not only in an EndUpdate() call, but also in a BeginUpdate() call. This will save us from all the efforts, performed to keep caches coherent between BeginUpdate() and EndUpdate() calls.
The attached test application gives results like:
- without the attached patch: 484 ms
- with the patch applied: 406 ms
Mantis conversion info:
- Mantis ID: 35333
- Build: 60857
- Version: 2.1 (SVN)
- Fixed in revision: 60868 (#db88431d)
- Target version: 2.2