Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Chart Control
  New Posts New Posts RSS Feed - Performance
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Performance

 Post Reply Post Reply
Author
Message
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Topic: Performance
    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 (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
Tomasz View Drop Down
Senior Member
Senior Member


Joined: 05 August 2006
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tomasz Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post 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 (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post 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 (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post 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 (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
m.geri View Drop Down
Newbie
Newbie


Joined: 24 July 2008
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote m.geri Quote  Post ReplyReply Direct Link To This Post Posted: 27 April 2011 at 3:09am
Back to Top
m.geri View Drop Down
Newbie
Newbie


Joined: 24 July 2008
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote m.geri Quote  Post ReplyReply Direct Link To This Post 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).

Back to Top
Simon HB9DRV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 July 2005
Location: Switzerland
Status: Offline
Points: 458
Post Options Post Options   Thanks (0) Thanks(0)   Quote Simon HB9DRV Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 02 May 2011 at 12:26pm
Thanks for the feedback, we are currently looking into the best approach to speed things up.
Back to Top
Simon HB9DRV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 July 2005
Location: Switzerland
Status: Offline
Points: 458
Post Options Post Options   Thanks (0) Thanks(0)   Quote Simon HB9DRV Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.