#52 Performance issues with TZID and iCalendar.LoadFromStream


When loading .ics files with TZID specified, it takes a very long time to parse the file. When the TZID is removed, the performance issues disappear.

I have observed large performance differences. For example, it took 24s to parse the ics file with TZID, compared with 0.016s without TZID.


  • Nobody/Anonymous

    ics file with TZID.

  • Mas

    Mas - 2010-11-23

    I have run the performance profiler to investigate further into this issue. I ran the profiler against 1.0.1 Beta.

    According to my run, 98% of the time parsing the iCalendar file is spent in the TimeZoneEvaluator.Evaluate method. Here's a breakdown:

    14% - RecurrencePatternEvaluator.Evaluate, line 824 [ if (!Periods.Contains(p)) ]
    14% - RecurringEvaluator.EvaluateRRule, line 68 [ if (!Periods.Contains(p)) ]
    37% - TimeZoneEvaluator.Evaluate, line 127 [ if (!Periods.Contains(period)) ]
    28% - TimeZoneEvaluator.Evaluate, line 131 [ if (!m_Occurrences.Contains(o)) ]

    Basically, all the time is spent searching through lists. I suspect using a Dictionary should improve performance vastly.

  • Doug Day

    Doug Day - 2011-02-24

    Sorry it's taken me so long to respond. I've been overwhelmed by other projects of late. I'm hoping to make some drastic improvements to performance within the next few weeks. Performance is one of the major issues still keeping version 1.0 in the Beta Candidate stage (rather then a full Beta). I'll let you know when I make progress on this.

    Thanks for reporting bugs! It helps a lot!

  • Comment has been marked as spam. 

    You can see all pending comments posted by this user  here

    Anonymous - 2011-03-02
  • Doug Miller

    Doug Miller - 2012-08-27

    There are several places in the source code where this statement is used:
    foreach(T o in list) if(!result.Contains(o)) result.Add(o);

    The "result" is of List<> type. A substitution of List<> with HashSet<> gives some increase of performance.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks