Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

High CPU usage wpf graph

Solved!
Go to solution

We are trying to plot data in a wpf graph, where adjuster is set to ContinuousChart and render mode is set to raster mode, but are seeing very high CPU usage. Data is residing in an ObservableCollection and new data is added with an interval of 0.1 seconds. I have attached an example, which is a slightly modified code I found in the forum (don’t remember which case). The code preloads 9000 points of data in four datasets and then continuous to add new data every 0.1 second. Initially the CPU usage is quite high, and continuous to increase as points are added. When the   number of points hits 10000 the CPU usage increase even further. What is the reason for the high CPU usage? Is there anything I can do to improve the CPU usage? I notice that it is not correlating to the number of points, if I start with 900000 points I get same CPU usage, why?  I do see that it correlates somehow to the data, i.e. the area inside the graph filled with lines between the datapoints.

0 Kudos
Message 1 of 4
(2,283 Views)
Solution
Accepted by topic author OddvarC

I have not had a chance to review things in detail, but wanted to cover some of the top points I noticed:

  • You are corrected to observe that graph performance is highly correlated with the number of samples being displayed on screen at one time. Samples that are outside the range of the plot area are discarded early, and do not need to be rendered.
  • You mentioned explicitly setting the graph to Raster render mode. The current recommendation is to use the Hardware render mode (which should be selected automatically by the graph for this type of workload, if it is not set explicitly).
  • You mentioned using ObservableCollection, which is a general-purpose collection that has not been optimized for data storage. For charting applications, the Measurement Studio chart collection types are the recommended approach, as these are optimized to work with the graph.

In fact, the project you attached looks like a (slightly modified) version of the Measurement Studio charting example, which uses a chart collection. Unfortunately, it will be hard to give more specific advice from an example that does not match your actual use case, but I hope these points help!

~ Paul H
0 Kudos
Message 2 of 4
(2,246 Views)

Hi,

 

I am sorry, I meant to write that data is residing in ChartCollections. You are correct, if I switch to hardware rendering the CPU drops significantly. Not sure what is going on with the raster rendering. Thanks for the recomandation link, hadn’t seen this page before.

 

Oddvar

0 Kudos
Message 3 of 4
(2,226 Views)

Hi,

 

One more thing. I tried having rendering in auto mode. But then CPU went high again. Hence, I need to set hardware mode explicitly, but I guess that should be fine.

 

Oddvar

0 Kudos
Message 4 of 4
(2,206 Views)