Page 1 of 1

response slowly when remove series from lots of series

Posted: Tue Jun 03, 2014 10:24 am
by 16566869
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);

}

Re: response slowly when remove series from lots of series

Posted: Tue Jun 03, 2014 2:42 pm
by yeray
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.

Re: response slowly when remove series from lots of series

Posted: Wed Jun 04, 2014 12:55 am
by 16566869
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?

Re: response slowly when remove series from lots of series

Posted: Wed Jun 04, 2014 1:12 am
by 16566869
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?

Re: response slowly when remove series from lots of series

Posted: Wed Jun 04, 2014 1:19 am
by 16566869
MY PC Spec. Information.
Dell Vostro 260
Intel Core i3-2120 CPU @ 3.3GHz
4.00G(2.92GB usable)

Re: response slowly when remove series from lots of series

Posted: Wed Jun 04, 2014 8:25 am
by yeray
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.