Search

performance problem in MSChart DataPointCollection.Clear() by selfcomposed

Closed
as Won't Fix Help for as Won't Fix

4
0
Sign in
to vote
Type: Bug
ID: 596212
Opened: 9/8/2010 12:42:25 PM
Access Restriction: Public
2
Workaround(s)
2
User(s) can reproduce this bug
The MSChart DataPointCollection.Clear() method is quite slow, taking about 5 seconds to delete 70k elements. It calls ClearItems(), which removes items from the *beginning* of the list until the list is empty.

protected override void ClearItems()
{
    this.SuspendUpdates();
    while (base.Count > 0)
    {
        this.RemoveItem(0);
    }
    this.ResumeUpdates();
}
Details (expand)

Visual Studio/Silverlight/Tooling version

.NET Framework 4

What category (if any) best represents this feedback?

 

Steps to reproduce

Fill a DataPointCollection with many elements, then Clear()

Product Language

English

Operating System

Windows XP

Operating System Language

English

Actual results

slow

Expected results

fast.

Recode ClearItems() to remove items from the *end* of the list.

protected override void ClearItems()
{
    this.SuspendUpdates();
    while (base.Count > 0)
    {
        this.RemoveItem(base.Count-1); // remove from end
    }
    this.ResumeUpdates();
}

File Attachments
0 attachments
Sign in to post a comment.
Posted by Pablo1397 on 8/8/2012 at 3:40 AM
For better performance Microsoft has to code in the class "ChartElementCollection<T>"

protected override void ClearItems()
{
    this.SuspendUpdates();
    while (base.Count > 0)
    {
        this.RemoveItem(base.Count - 1);
    }
    this.ResumeUpdates();
}
Posted by Microsoft on 2/3/2011 at 11:27 PM
Thank you for reporting this issue. At this time, we do not have plans to address this issue

-Sean
Posted by Microsoft on 9/8/2010 at 5:02 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Pablo1397 on 8/8/2012 at 3:43 AM
a better solution is:

    public void ClearPointsQuick()
        {
            Points.SuspendUpdates();
            while (Points.Count > 0)
                Points.RemoveAt(Points.Count - 1);
            Points.ResumeUpdates();
            Points.Clear();
        }
Posted by selfcomposed on 9/8/2010 at 12:43 PM
    public void ClearPointsQuick()
        {
            Points.SuspendUpdates();
            while (Points.Count > 0)
                Points.RemoveAt(Points.Count - 1);
            Points.ResumeUpdates();
        }