What I have learned so far with uBootstrap, Razor views and MiniProfiler for Umbraco
When I started profiling uBootstrap with the MiniProfiler for Umbraco I noticed something very strange… the homepage was taking about 600ms to load, making more that 100 database calls and spending 1/3 of the time in sql.
Then I started chasing down those database calls and trying to find out why some razor views where taking so long to render. This is what I discovered…
DynamicNode syntax hurting the performance
One of the features I loved about the DynamicNode razor syntax is that you can do some stuff like item.Texpages to retrieved the child item with document type alias Textpage. I also like that this could help the code to be more readable. Then I discovered this syntax could hurt the performance and loading time of a particular macro. Let’s have the Navigation.cshtml as example. In the past, I did something like this:
and only took 4.5ms. FOUR POINT FIVE MILLISECONDS! That’s a great improvement. Also, no database calls
Results after tuning razor view
After modifying my razor views, the homepage is being loaded in about 47ms without any caching. I could probably make it even better by setting caching the views RelatedLinks.cshtml and LanguageSelector.cshtml as they are shared all across the website. You can compare the slow macros in the MiniProfiler source code with the uBootstrap source code.