Print Page | Close Window

Performance

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Chart Control
Forum Description: Topics Related to Codejock Chart Control
URL: http://forum.codejock.com/forum_posts.asp?TID=18210
Printed Date: 12 May 2024 at 10:47am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Performance
Posted By: cpede
Subject: Performance
Date Posted: 12 April 2011 at 10:52am

Now I finally changed my existing ComponentOne Chart graph component with the CXTPChart component. My first experience is, that I really hope that I do something very wrong, since the performance is very bad compared.

My main loop for updating data is like this:

SetUpdateWindow(FALSE);
m_pSeries->GetPoints()->RemoveAll();
for (int i=0;i<20000;i++)
{
  double dData = pData[i];
  double dX = (double)i;
  double dY = (double)dData;
  m_pSeries->GetPoints()->Add(new CXTPChartSeriesPoint(dX,dY));
}
SetUpdateWindow(TRUE);

The remove and the loop takes around 6 seconds to run!

What can I do to boost performance, Component Chart uses 750 msec for the same action! The time measurements are made in debug builds, so I guess that the performance is slightly better in release.

-cpede



-------------
Product: Xtreme ToolkitPro (22.1.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)



Replies:
Posted By: Tomasz
Date Posted: 23 April 2011 at 1:29pm

It is not surprising that chart component is slow given its current architecture (each data point being a separate object created on heap). new operator is slow. 

My in-house developed charting components can add 3 *million* data points and draw candlestick chart with 3 million bars in under 0.15 seconds. But it is written in pure C and it allocates one contiguous array for all data points at once (in one HeapAlloc call).

If you want speed there is no choice - you have to write code yourself. I am yet to see any commercial chart component that delivers performance required for demanding real-time charting applications.



Posted By: cpede
Date Posted: 26 April 2011 at 2:55am
Well, looking at the .NET-like object way CodeJock has implemented it you are right.
 
But I must say that I'm  actually very disappointed. I', using C++/MFC because of the performance. I have a lot of colleagues writing C#/.NET code and every time I can out-perform regarding performance and efficiency. And thanks to CodeJock I can also make GUI code just as fast as they can. When CodeJock then comes out with a chart control I was actually expecting performance, but what we got was just another slow chart component,  probably good for financial charts with up to 100 samples. You can find a trillion of these kind of component on the Internet, good looking but with bad performance. I will go back to ComponentOne Chart until CodeJock at least comes
close to that performance.
 
-cpede


-------------
Product: Xtreme ToolkitPro (22.1.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)


Posted By: adrien
Date Posted: 26 April 2011 at 6:51am
there are several things you could do perhaps to speed up your loop.

1. Don't call m_pSeries->GetPoints() each loop, cache the result
2.Tell the array how many points beforehand (CArray::SetSize()) so it doesn't need to do 20000 reallocs

Cheers

Adrien



-------------
http://www.wingate.com - http://www.wingate.com


Posted By: cpede
Date Posted: 26 April 2011 at 7:02am
Can I do anything to replace the pPoints->RemoveAll() call, if I know that I just need to fill it up again? Maybe with less points?
 
-cpede


-------------
Product: Xtreme ToolkitPro (22.1.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)


Posted By: adrien
Date Posted: 26 April 2011 at 7:29am
I wouldn't have thought RemoveAll would be that expensive.  Have you tried tracing tick counts to see how long it even takes?

-------------
http://www.wingate.com - http://www.wingate.com


Posted By: cpede
Date Posted: 26 April 2011 at 8:18am
You are right, and the changes you proposed did not do anything for the performance either. Adding and removing seems to just add and remove from an array, and this is ok fast.
The problem is the drawing or rendering:
 
Enabling the performance counter already added in XTPChartControl gives the following result
CXTPChartControl::OnPaint: 150957246
for 3 CXTPChartFastLineSeriesStyle series with 10000 samples each.
 
Which gives approx. 10.5 sec. !
 
-cpede
 
 
 


-------------
Product: Xtreme ToolkitPro (22.1.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)


Posted By: m.geri
Date Posted: 27 April 2011 at 3:09am


Posted By: m.geri
Date Posted: 27 April 2011 at 3:37am
I tried to add 10,000 points to the Fast Line sample with 5 lines  and it works quite well probably because the view range on X axis is 100 points.
Increasing the number of points of view range to 1000 painting and scrolling is very slow and graph that is obtained is not readable because the lines overlap with each other.
One solution could be to  be able to to set the maximum number of data points displayed at once. If the viewer, for example using zoom, selects a period that contains more data points than that this number, the chart groups data into longers periods using a "grouping" function (for example average).



Posted By: Simon HB9DRV
Date Posted: 27 April 2011 at 7:12am
Sadly I agree about performance - having looked at the code I see why. I would like to see much better performance - I'm sure Codejock can increase speed by at least an order of magnitude. Performance at the moment is horrible Cry but visually it's great Wink !

-------------
Simon HB9DRV


Posted By: SuperMario
Date Posted: 02 May 2011 at 12:26pm
Thanks for the feedback, we are currently looking into the best approach to speed things up.


Posted By: Simon HB9DRV
Date Posted: 02 May 2011 at 1:03pm
Originally posted by SuperMario SuperMario wrote:

Thanks for the feedback, we are currently looking into the best approach to speed things up.
 
I'm sure you'll do it - keep up the good work, my users love it.


-------------
Simon HB9DRV



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net