DataPointCollection 清晰的性能
我有这 2 个示例:
1 示例:
Series seria = new Series("name");
for(int i = 0 ; i < 100000 ; i++)
{
seria.Points.Add(new DataPoint(i, i));
}
seria.Points.Clear(); // - this line executes 7.10 seconds !!!!!!!!!!
Series
是来自 System.Windows.Forms.DataVisualization
dll
2 示例:
List<DataPoint> points = new List<DataPoint>();
for (int i = 0; i < 100000; i++)
{
points.Add(new DataPoint(i, i));
}
points.Clear(); // - this line executes 0.0001441 seconds !!!!!!!!!!
- 为什么这些Clear方法之间差异如此之大?
- 我怎样才能更快地清除 seria.Point ?
I have this 2 examples:
1 Example:
Series seria = new Series("name");
for(int i = 0 ; i < 100000 ; i++)
{
seria.Points.Add(new DataPoint(i, i));
}
seria.Points.Clear(); // - this line executes 7.10 seconds !!!!!!!!!!
Series
is class from System.Windows.Forms.DataVisualization
dll
2 Example:
List<DataPoint> points = new List<DataPoint>();
for (int i = 0; i < 100000; i++)
{
points.Add(new DataPoint(i, i));
}
points.Clear(); // - this line executes 0.0001441 seconds !!!!!!!!!!
- Why there is so huge difference between those Clear methods?
- And how can I clear seria.Point faster ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个众所周知的问题: MSChart DataPointCollection.Clear() 中的性能问题
建议的解决方法如下所示:
本质上,在清除点时,数据可视化工具应该已经暂停更新,但事实并非如此!因此,上述解决方法的工作速度将比简单地调用 Points.Clear() 快一百万倍(当然,直到实际错误修复为止)。
This is a very well known problem: performance problem in MSChart DataPointCollection.Clear()
Suggested workaround is like below:
Inherently, while clearing points the data visualizer should suspend the updates already, but it doesn't! So above workaround will will work about a million times faster than simply calling
Points.Clear()
(of course until the actual bug is fixed).