Improving speed of plotting bursts of points in large graph
Posted: Fri May 12, 2006 1:31 pm
When a 'burst' of a few points (say 1000 points) is added (say every 100 milliseconds) to a graph of many points (say almost 1,000,000 points) over a long time period (in this case 100 seconds) using FastLine->AddXY(), and then the graph is cleared and plotting started all over again, I found that the plotting was VERY CPU INTENSIVE primarily because of the allocation/deallocation/reallocation/deallocation of memory that takes place during the continual graph plotting/clearing/plotting/clearing.
I subsequently found that just using DynamicArrays with the Repaint() mechanism DOES NOT WORK because towards the end of the graph, adding and plotting 1000 points requires adding 1000 points to the DyanmicArrays, but REPAINTING almost 1,000,000 points rather than only the REQUIRED NEW 1000 points is VERY CPU INTENSIVE!!!
In order to stop this wasteful allocation/deallocation/reallocation/deallocation there are two things that could be done to decrease the MASSIVE CPU USAGE:
1) Stop the continuous allocation/deallocation/reallocation/deallocation of memory that goes with using FastLineSeries->Add_XY()
I found that there is a Capacity of a "TeEngine" that could be changed for Lists (e.g.):
"TeeDefaultCapacity Unit TeEngine
Description: This variable determines the number of points that the Series will preallocate when adding points. This number is used to resize the internal arrays. The concept is similar to Borland's TList "Capacity" property, but used with arrays and the SetLength method. Setting a high value (for example one million), will pre-allocate memory space for one million points, so, when adding lots of points, there will not be time spent allocating memory until one million points have been added."
But this does work for TFastLineSeries or TLineSeries (I tried putting in this code but it was rejected by the compiler, C++ Builder 6, TeeChart Pro 6)
FastLineSeries1->Capacity = 1000000; // ERROR, Capacity is not a member of TFastLineSeries
LineSeries1->Capacity = 1000000; // ERROR, Capacity is not a member of TLineSeries
Could changing the Capacity of a FastLineSeries be used to change the amount of preallocated memory for a FastLineSeries so that the wasteful allocation/deallocation/reallocation/deallocation cycle does not have to occur?
2) A possibly easier solution would be to use DynamicArrays, but have a 'RepaintNew()' method to plot/paint ONLY those new points added to the DynamicArrays after the last plot/paint has occurrred.
COULD YOU PLEASE IMPLEMENT AT LEAST ONE OF THESE SOLUTIONS!
Thanks,
Bill
I subsequently found that just using DynamicArrays with the Repaint() mechanism DOES NOT WORK because towards the end of the graph, adding and plotting 1000 points requires adding 1000 points to the DyanmicArrays, but REPAINTING almost 1,000,000 points rather than only the REQUIRED NEW 1000 points is VERY CPU INTENSIVE!!!
In order to stop this wasteful allocation/deallocation/reallocation/deallocation there are two things that could be done to decrease the MASSIVE CPU USAGE:
1) Stop the continuous allocation/deallocation/reallocation/deallocation of memory that goes with using FastLineSeries->Add_XY()
I found that there is a Capacity of a "TeEngine" that could be changed for Lists (e.g.):
"TeeDefaultCapacity Unit TeEngine
Description: This variable determines the number of points that the Series will preallocate when adding points. This number is used to resize the internal arrays. The concept is similar to Borland's TList "Capacity" property, but used with arrays and the SetLength method. Setting a high value (for example one million), will pre-allocate memory space for one million points, so, when adding lots of points, there will not be time spent allocating memory until one million points have been added."
But this does work for TFastLineSeries or TLineSeries (I tried putting in this code but it was rejected by the compiler, C++ Builder 6, TeeChart Pro 6)
FastLineSeries1->Capacity = 1000000; // ERROR, Capacity is not a member of TFastLineSeries
LineSeries1->Capacity = 1000000; // ERROR, Capacity is not a member of TLineSeries
Could changing the Capacity of a FastLineSeries be used to change the amount of preallocated memory for a FastLineSeries so that the wasteful allocation/deallocation/reallocation/deallocation cycle does not have to occur?
2) A possibly easier solution would be to use DynamicArrays, but have a 'RepaintNew()' method to plot/paint ONLY those new points added to the DynamicArrays after the last plot/paint has occurrred.
COULD YOU PLEASE IMPLEMENT AT LEAST ONE OF THESE SOLUTIONS!
Thanks,
Bill