在C#(.NET)图表控件使用的CPU吨 [英] Chart Control in C# (.NET) Uses Tons of CPU

查看:176
本文介绍了在C#(.NET)图表控件使用的CPU吨的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是FastLineChart在C#中显示的实时外部设备的信号。采样率约为为700Hz。在我的节目,我下采样到100Hz左右,以尽量减少不必要的分辨率的显示,但仍使用太多的CPU这样做。

I am using a FastLineChart in C# to display a signal from an external device in real time. The sample rate is about 700Hz. In my program I down-sample to about 100Hz to minimize unnecessary resolution for the display, but still use way too much CPU doing this.

我觉得问题是,我的滚动数据在图表(如CPU图确实在Windows中),这是吃了资源。我这样做删除最旧的元件,然后添加一个新的具体系列(如下所示)。

I think the problem is that I am scrolling the data across the chart (like the CPU graph does in windows) and this is eating up resources. I do this by removing the oldest element and then adding a new one to the specific series (as shown below).

timeGraph.Series[0].Points.RemoveAt(0);
timeGraph.Series[0].Points.AddY(average);

CPU负载为30%左右,我认为是一个有点太高。我没有最新的电脑,但它是一个code 2双核与GT9600显卡。

The CPU load is about 30% which I think is a bit too high. I do not have the newest computer, but it is a Code 2 Duo with GT9600 graphics card.

有没有人有什么建议?有没有更好的办法做到这一点?或者一种特定的方式,使这个更快?

Does anyone have any suggestions? Is there a better way to do this? Or a specific way to make this faster?

感谢您的帮助!

推荐答案

好了,老回答的问题,但我坚持类似这样的年龄的一个问题,所以对于任何人谁发现这一点:

Ok, so old question to answer, but i was stuck with a problem similar to this for ages, so for anyone who finds this:

要停止大规模的CPU占用率:

To stop the massive CPU usage:

1)声明一个整数

int graphUdate = 0;

2)form_负荷,增加

2) in form_ load, add

chart1.Series.SuspendUpdates();

3)添加一个点到你的图形时,使用

3) when adding a point to your graph, use

graphUpdate++;

4)在同一个空间,更新图中每个#点数和复位graphUpdate

4) in the same space, update the graph every # number of points and reset graphUpdate

if (graphUpdate == #)
            {
                chart1.Series.ResumeUpdates();
                chart1.Series.Invalidate();
                chart1.Series.SuspendUpdates();
                graphUpdate = 0;
            }

该更新)自从上次chart1.Series.SuspendUpdates(收集了所有点;

this updates all point gathered since the last chart1.Series.SuspendUpdates();

去除点也将暂停,作出了重大差异的CPU使用率。

the removal of points will also be suspended, making a MAJOR difference to CPU usage.

这篇关于在C#(.NET)图表控件使用的CPU吨的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆