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?
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.
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.
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?
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
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.
is working on a reply...