TAChart: added caching for cumulative and list extents
Original Reporter info from Mantis: Marcin Wiazowski
-
Reporter name:
Original Reporter info from Mantis: Marcin Wiazowski
- Reporter name:
Description:
Currently, only basic extent is cached, as can be seen in TCustomChartSource.BasicExtent(). So I'm attaching a patch, that adds caching also for cumulative and list extents (that are used by multi-value data sources).
To make analysis of changes introduced by the patch easier, I'm attaching in fact two files:
* The attached patch_partial.diff introduces some initial code rearrangements:
- Whenever I can see "BasicExtent" in the code, I immediately know what it is; and when I can see just "Extent", I'm not sure with which inheritance level I'm dealing with. So, to make the code more understandable, I decided to rename TCustomChartSource strict protected fields from:
FExtent: TDoubleRect;
FExtentIsValid: Boolean;
to:
FBasicExtent: TDoubleRect;
FBasicExtentIsValid: Boolean;
This change of course can be reverted, but I find it quite useful. It impacts only TCustomChartSource and TListChartSource.
-
Some lacking code was added to SetDataItemDefaults() procedure.
-
TCustomChartSource.CalcExtentXYList() and TCustomChartSource.ExtentCumulative() methods are very similar - some adjustments were made to make them even more similar. In addition, their code has been rearranged, as it will be needed for caching.
-
I renamed the private TListChartSource.ClearCaches() method to InitializeEmptyCaches(), because the name was no longer describing the current functionality properly.
* The attached patch_full.diff fully contains patch_partial.diff, and adds caching to TCustomChartSource and TListChartSource. I think that introduced changes are rather self-explaining.
The attached MultiExtentSpeedTest application gives results like:
- test ExtentCumulative: 1650 ms
- test ExtentList: 850 ms
- test ExtentXYList: 1650 ms
After applying patch_full.diff:
- test ExtentCumulative: 25 ms
- test ExtentList: 15 ms
- test ExtentXYList: 25 ms