response slowly when remove series from lots of series

TeeChart FireMonkey (Windows,OSX,iOS & Android) for Embarcadero RAD Studio, Delphi and C++ Builder (XE5+)
Post Reply
elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

response slowly when remove series from lots of series

Post by elmec » Tue Jun 03, 2014 10:24 am

As the code showing below,
I want to remove series spedified from 1500 series.
The series deleting didn't take much time...
but the code behind it

Code: Select all

(ShowMessage(diff);)
didn't show until 2-3 seconds later..
Please find the attachment for the example project.

Code: Select all

__fastcall TForm12::TForm12(TComponent* Owner)
	: TForm(Owner)
{
	int count   = 1500;
	int datalen = 200;
	for (int i = 0; i < count; i++)
	{
		TFastLineSeries* series = new TFastLineSeries(Chart1);
		series->ParentChart = Chart1;
		series->DrawAllPoints = false;
		series->FastPen = true;
		series->FillSampleValues(datalen);
    }

}


void __fastcall TForm12::btnRemoveClick(TObject *Sender)
{

	DWORD dwBegin, dwEnd;
	dwBegin = dwEnd = GetTickCount();

	// Remove the series specified by "edtSeriesNo"
	int no = edtSeriesNo->Text.ToInt();
	delete  Chart1->Series[no];

	dwEnd = GetTickCount();

	DWORD diff = dwEnd - dwBegin;

	// The result of "diff" is about 0,
	// but the MessageBox showed about 2-3 seconds later
	ShowMessage(diff);

}
Attachments
RemoveSeries.zip
(257.08 KiB) Downloaded 1324 times

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: response slowly when remove series from lots of series

Post by Yeray » Tue Jun 03, 2014 2:42 pm

Hello,

It's almost instantly for me here, and the dialog shows 0 most of the times I press the button.
I tried to force a chart repaint after removing the series, then the dialog shows between 100~200 every time.

Code: Select all

void __fastcall TForm12::btnRemoveClick(TObject *Sender)
{

	DWORD dwBegin, dwEnd;
	dwBegin = dwEnd = GetTickCount();

	// Remove the series specified by "edtSeriesNo"
	int no = edtSeriesNo->Text.ToInt();
	delete  Chart1->Series[no];
	Chart1->Draw();

	dwEnd = GetTickCount();

	DWORD diff = dwEnd - dwBegin;

	// The result of "diff" is between 100~200
	ShowMessage(diff);
}
I've also tried with less series. If you only add 10 series and you remove the series 0, you don't need to force a chart repaint to see the series disappear. So the chart seems to be correctly automatically repainted, but the dialog still shows 0.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

Re: response slowly when remove series from lots of series

Post by elmec » Wed Jun 04, 2014 12:55 am

BTW, I am using Teechart2014 for C++ Builder XE4 HD App.
I think the delay duration until DialogBox show
should be that main thread is waiting teechart automatic repaiting after series removed..

Can you reproduce with the EXE I have sent to you?
Is there any idea to improve that?

elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

Re: response slowly when remove series from lots of series

Post by elmec » Wed Jun 04, 2014 1:12 am

I tried to set AutoRepaint to false, and the DialogBox showed instantly.
Off course, too repaint the TChart, we still need to call Repaint() func,
then it block the main thread for about 2 seconds here..nothing changed!
So maybe I need a thread to repaint the TChart?

I don't know why it is so slow.
Only Teechart for c++ builder xe is slow? delphi version is fast?

elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

Re: response slowly when remove series from lots of series

Post by elmec » Wed Jun 04, 2014 1:19 am

MY PC Spec. Information.
Dell Vostro 260
Intel Core i3-2120 CPU @ 3.3GHz
4.00G(2.92GB usable)

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: response slowly when remove series from lots of series

Post by Yeray » Wed Jun 04, 2014 8:25 am

Hello,

Note you are drawing 1500 * (24-8+1) = 25500 points and this takes some time.
Adding the Chart->Draw after the series removal, you can measure the exact time it takes to repaint the chart.
For me, it's about 220~240 ms, but as you've noticed, this depends on the machine specifications and also on the chart settings.
Setting DrawAllPoints to false doesn't help in this concrete example because we have a bottom axis range of 17, so we don't have points of the same series being drawn in the same x-pixel.
Some other tips you could try to implement in your chart to optimize the performance are listed here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply