Speed up Live Plotting?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
moelski
Newbie
Newbie
Posts: 92
Joined: Tue Jun 19, 2007 12:00 am
Contact:

Re: Speed up Live Plotting?

Post by moelski » Mon Jun 07, 2010 6:48 am

@MTW, Narcis
When the program first starts running, the CPU usage stays about 12%. As data is added, the CPU usage slowly increases and reaches a steady 30% when the max data is added and the scrolling begins
That´s exactly the same as my results.

@Narcis:
I send a demo project some time ago. Why don´t you use that? :(

The problem in CPU usage is in Unit TeEngine
procedure TChartValueList.RecalcStats(StartIndex:Integer);

There is a for which always loops through all points of the chart to compute FMinValue, FMaxValue, FTotal, FTotalABS.

To be honest I can´t beleave that there is no better way to make these calculations. As I said before ... My code enhancements working fine. And if you find some cases where my fix may result in trouble you could implement a workaround for that.

Actually RecalcStats slows down the whole engine enormously and I can´t understand why you don´t try to fix this important issue.

@MTW:
Do you have the source code of tchart? Maybe I can send you my fixed teengine.pas for testing?

Greetz Dominik

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Speed up Live Plotting?

Post by Narcís » Mon Jun 07, 2010 12:06 pm

Hello,
MTW wrote:I sent a simple demo through the upload page. To monitor the CPU usage, I ran Windows Task Manager and monitored the CPU usage of the process. When the program first starts running, the CPU usage stays about 12%. As data is added, the CPU usage slowly increases and reaches a steady 30% when the max data is added and the scrolling begins.
Thanks for the example project. I could reproduce the issue here and checked CPU usage highly depends on machine's CPU power. In that case, you could try if using DownSampling function instead of displaying complete series enhances the performance at your end. You'll find an example at the All Features\Welcome!\Functions\Extended\Reducing number of points in the new features demo, available at TeeChart's program group. You'll also find an explanation of how it works here.
moelski wrote:I send a demo project some time ago. Why don´t you use that? :(

The problem in CPU usage is in Unit TeEngine
procedure TChartValueList.RecalcStats(StartIndex:Integer);

There is a for which always loops through all points of the chart to compute FMinValue, FMaxValue, FTotal, FTotalABS.

To be honest I can´t beleave that there is no better way to make these calculations. As I said before ... My code enhancements working fine. And if you find some cases where my fix may result in trouble you could implement a workaround for that.

Actually RecalcStats slows down the whole engine enormously and I can´t understand why you don´t try to fix this important issue.
I already answered that earlier on the thread, see this post. Have you tested your modifications in different kind of charts and situations? Do they work fine for you in all circumstances? We have no inconvenient you using your code tweaks if they work fine for you.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

moelski
Newbie
Newbie
Posts: 92
Joined: Tue Jun 19, 2007 12:00 am
Contact:

Re: Speed up Live Plotting?

Post by moelski » Mon Jun 07, 2010 12:46 pm

Hi Narcis,
Have you tested your modifications in different kind of charts and situations
Yes and until now it worked for us.
We have no inconvenient you using your code tweaks if they work fine for you
I think you missunderstood the main problem ...
For sure I can tweak the code so that it works for me. But keep in mind that I have to change the code every time I install a new version of TChart.
You should agree with me that there is an speed issue and this should not be fixed by users. It should be fixed by you :)
You'll find an example at the All Features\Welcome!\Functions\Extended\Reducing number of points in the new features demo
If I add 15000 points it get´s very slow ...

Greetz
Dominik

MTW
Newbie
Newbie
Posts: 21
Joined: Thu Jun 28, 2007 12:00 am

Re: Speed up Live Plotting?

Post by MTW » Tue Jun 08, 2010 3:31 pm

Thank you for your suggestions of reducing the number of points plotted. I am actually doing that myself in the application, but when the user selects the highest sampling rate, I can't do any further data reduction.

If you had a way to add XValues and YValues (arrays) to existing data, that should cut down tremendously on the computation, by being only computed once per set of data added. Is there an easy (quick) way to load up a dynamic array from the graph X,Y Values, so that I could then append the new data to that array, and then replace the X,Y Values with the new array? Would that be less CPU intensive?

The truth is that I am not as concerned with speed as I am with CPU resources. When there is a lot of data in the graph and I add new data, the system becomes sluggish in responding to mouse clicks elsewhere in the application. Is there a way to idle the thread without tremendously slowing down everything? (Application->ProcessMessages in between points slows down everything to the point that it is not acceptable.)

Thanks
M Weingarden

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Speed up Live Plotting?

Post by Narcís » Thu Jun 10, 2010 2:07 pm

Hi MTW,
If you had a way to add XValues and YValues (arrays) to existing data, that should cut down tremendously on the computation, by being only computed once per set of data added. Is there an easy (quick) way to load up a dynamic array from the graph X,Y Values, so that I could then append the new data to that array, and then replace the X,Y Values with the new array? Would that be less CPU intensive?
You can directly add values to series arrays as shown in the Real-time Charting article here. However, adding an array replaces existing series values. You should concatenate arrays yourself before populating series. In the wish-list we have a feature request (TV52014513) which consists on supporting automatic array concatenation using AddArray method. This already exists in TeeChart for .NET and I have increased its priority to be considered for inclusion in TeeChart VCL.
Is there a way to idle the thread without tremendously slowing down everything?
TeeChart is not thread safe. You need to give the chart time enough to paint itself. This can be controlled with asynchronous painting technique using AutoRepaint property, which is already demonstrated in the Real-time Charting article. IIRC you already did that in your example project.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply