ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  High CPU Usage
Posted by zdw on Jun-16-2020 14:41
Attachments:
in the wxWidgets FrameWork,We used the wxChartDir library to experience high CPU usage.I don't know how to solve it at present. Ask for help!!!
7d7e8197b703e1fa0bbe5fe9ea375e6.png

  Re: High CPU Usage
Posted by Peter Kwan on Jun-17-2020 02:00
Hi zdw,

Note that wxChartDir is not from us. It is from one of our customers who ported the C++ MFC/Qt sample code to wxWidgets. We ourselves are not familiar with wxWidgets and I have never used it before.

From your screenshot, the MemBlock m = c->makeChart(Chart::BMP); line is the last line that executes ChartDirector code. It draws the chart as an image in memory. The next 4 lines seems to be for displaying the image in wxWidgets.

For the code, I would expect the "MemBlock m = c->makeChart(Chart::BMP);" will take the longest CPU time, because it needs to compute hundreds of thousands or even millions of pixels. The wxWidget code seems to be only copying the pixels and should not take long.

If you think the wxImage and wxBitmap takes unusually long time, you may do a test yourself to double check how much time they take. The performance value in your development tool can be inaccurate. It is better to test it youself. For example, you can create a loop to draw the chart 100 times to see how long it takes. Then you can comment out the wxBitmap and the next two lines and see how long it takes to run 100 times. If the wxBitmap and wxImage really takes a long time, removing them should improve the speed by 10 times or more. This can verify if the performance value is correct.

Note that for performance testing, you should run the code in "Release" mode (not Debug mode), and you should not run it inside the debugger. The debugger or Debug mode code can significant change the performance.

Regards
Peter Kwan

  Re: High CPU Usage
Posted by Ulrich Telle on Jul-07-2020 05:43
zdw wrote:

in the wxWidgets FrameWork,We used the wxChartDir library to experience high CPU usage.I don't know how to solve it at present. Ask for help!!!

Could you please provide some more information about your environment? Which version of wxWidgets do you use? Which compiler? What is the dimension of the graphics (width and height in pixels)?

As Peter already wrote, the conversion from the ChartDirector bitmap to a wxBitmap should usually not incur high CPU usage. However, this might not be true for very large bitmaps.

BTW, if you experience problems with wxChartDir, you may always ask for help on the wxChartDir issue tracker: https://github.com/utelle/wxchartdir/issues . That will get my attention faster than posts on this ChartDirector forum.

  Re: High CPU Usage
Posted by zdw on Jul-22-2020 13:54
Attachments:
Ulrich Telle wrote:

zdw wrote:

in the wxWidgets FrameWork,We used the wxChartDir library to experience high CPU usage.I don't know how to solve it at present. Ask for help!!!

Could you please provide some more information about your environment? Which version of wxWidgets do you use? Which compiler? What is the dimension of the graphics (width and height in pixels)?

As Peter already wrote, the conversion from the ChartDirector bitmap to a wxBitmap should usually not incur high CPU usage. However, this might not be true for very large bitmaps.

BTW, if you experience problems with wxChartDir, you may always ask for help on the wxChartDir issue tracker: https://github.com/utelle/wxchartdir/issues . That will get my attention faster than posts on this ChartDirector forum.

We use the financial chart to refresh once per second and auto layout. Even without a refresh, CPU usage can go from around 10% to 26%
1595382697(1).png

  Re: High CPU Usage
Posted by Ulrich Telle on Jul-22-2020 14:34
We use the financial chart to refresh once per second and auto layout. Even without a refresh, CPU usage can go from around 10% to 26%

I suspect that the size of the graphics might be the cause. However, if you want me to look into this, please provide some more information about your environment:

- Which version of wxWidgets do you use?
- Which compiler do you use?
- What is the dimension of the graphics? That is, is the size of your attached graphics the typical size?

Thanks.

  Re: High CPU Usage
Posted by Ulrich Telle on Jul-23-2020 23:31
In the meantime I inspected the underlying wxWidgets code for transforming the BMP graphics delivered by ChartDirector to a wxBitmap object as required by the wxDC class for drawing a bitmap on screen.

Unfortunately, wxWidgets doesn't offer methods, which would allow to perform this conversion more efficiently being still platform independent.

OTOH I made a few tests with larger graphics and I didn't experience any serious performance problems. Even refreshing every 50 ms worked flawlessly. Of course, the CPU load increases proportionally with the size of the graphics and the refresh rate.