Friday, October 7, 2011

Umbraco Model and DynamicNode overhead

Just a quick post to show something interesting I discovered with Umbraco 4.7.1.

These 3 if statements do the same thing. However the first 2 turn out to be 2-3 times more expensive in terms of execution time.

if (Model.title == null)

if (Model.title is umbraco.MacroEngines.DynamicNull)

var current = new DynamicNode(Model.Id);
if (current.GetProperty("title") != null)

What's more, is that if you call AnscestorOrSelf() on Model vs current (my instantiated DynamicNode) there is a doubling of those results.

It seems that there is some extra overhead going on with Model.


Chris Ashton said...

Yet another issue with Umbraco that makes little sense. I will be glad when version 5 is done and they hopefully make these things clearer.

They could have used something like "GetModel" versus "GetCurrentModel" to make it more obvious.

Nicely done, and VERY interesting. Thanks for a great post. Sherlock Holmes himself would be impressed!

Post a Comment