Saturday, October 8, 2011

Umbraco Model and DynamicNode overhead part 2

The results from the previous post were from a page which had a few macros on it. In true scientific fashion I decided to isolate the issue. I downloaded a fresh copy of Umbraco from the web matrix and ran it on iis express.

I made a doctype with nothing except a title. I made 2 templates and 2 macroscripts. One using Model, the other using DynamicNode.

Here are the macroscripts:

Model macroscript

DynamicNode macroscript
@using umbraco.MacroEngines
DynamicNode d = new DynamicNode(Model.Id);

The 2 following images are example traces (Model followed by DynamicNode). I am interested in the time it takes for the macro to finish loading. Ie. the last line Loading IMacroEngine script [done]


Dynamic Node

Here is a table of results showing the Loading IMacroEngine script [done] line:

Dynamic node loaded on average 0.000041646741092 seconds faster than Model.

This does not seem like much, but it is interesting that instantiating a DynamicNode and getting a value from it is quicker than getting a value from Model. I was told that Model is dynamic but is actually a DynamicNode also. It sort of makes sense that a dynamic object would be more intensive than a typed one (even of the same type).

I'm wondering if there is some sort of effect of having multiple scripts (or nested scripts, or even possibly nested masterpages) on the page which compounds the time taken to load a single macro, and hence causing the script to load slower in the previous post.

I would be interested if people had some input.

I decided to run the tests again except checking if the value is null.

Quick results...
Average (Model)
Average (DynamicNode)


So the difference is larger when you start doing things with Model.


Markus said...

Feels like alot of testing for a very little benefit? I mean, optimize client-side load, scripts and styles would make the site feel alot faster than tweaking a server side script to perform 0.000042 sekunds faster.

Anthony said...

I've been dealing with performance of a lot of nodes lately. Imagine you have 10000 nodes where you want to check a property of.

You should be optimising the client side anyway ;)

Post a Comment