Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Valerie 67 posts 163 karma points
    Mar 23, 2015 @ 12:27
    Valerie
    1

    Performance of DynamicPublishedContent

    Hello,

    We have noticed some real speed differences between IPublishedContent and DynamicPublishedContent

    Ignoring the fact this is just silly test code, this is the good code with IPublishedContent

    This is the bad code with DynamicPublishedContent

    The main difference seems to be the "where" clause when using the DynamicPublishedContent. It's fast to load all the children, then falls apart.  Are we doing something wrong?

     

     

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 23, 2015 @ 12:58
    Matt Brailsford
    2

    I would imagine that using DynamicPublishedContent is always going to be slower as it basically wraps IPublishedContent and then on the fly makes it all dynamic.

    DynamicPublishedContent.Children specifically could be performance heavy as calling .Children will generate a DynamicPublishedContentList is it itself populated by iterating over every child item of it's wrapped IPublishedContent, so in reality, you'll be iterating twice compared to the once a strongly typed IPublishedContent.Children collection call would. (I'm not sure if adding a .ToList() after your where clause in the dynamic version could help some, in case the enumeration causes the list to be created multiple times, but could be worth a try).

    Ultimately though, DynamicPublishedContent will always end up being slower than it's IPublishedContent counterpart, it just make things a bit less verbose in some areas which is why some people like it. If it's causing a real drain though, it might be time to look at going strongly typed and using IPublishedContent instead.

    Matt

  • Valerie 67 posts 163 karma points
    Mar 23, 2015 @ 13:00
    Valerie
    0

    Hi Matt,

    Thanks for that. We have reverted back to using IPublishedContent for the time being - it was just quite a shock how big the difference in performance was.

Please Sign in or register to post replies

Write your reply to:

Draft