I recently queried the former Lead Developer at my current place of employment as to why he chose to use the Razor Generator to pre-compile our views in to a separate assembly.
He made some claims below, but I can't seem to find any Razor Generator profiles and/or metrics on the web to back up the claim (10-100 times faster), and/or, if what IIS7/ASP.NET does behind the scenes regarding pre-compiled vs. runtime-compiled views and their benefit or the lack-there-of.
Can anyone point me in the right direction? Or comment?
It seems to me (as far as startup time is concerned) simply setting IIS autostart = true
for the site would balance out any benefit of pre-compiling using the Razor Generator. Here is his statement:
Why are we using the Razor Generator to pre-compile our views and why put them in a separate assembly?
The first is simple, compile-time error checking. With this many views it seemed like a great way to avoid errors on production. It's a bit frustrating having to recompile to see the changes to the views I admit, but it is (in my opinion) totally worth it to know that you have that much more error checking upfront.
The second is that when the views aren't compiled in a project they get compiled at runtime and then those compiled representations have to be stored in ram. Sometimes, if they're not accessed regularly (which is the case with most of those views since there are so many) those stored compiled versions get abandoned and garbage collected to save ram. So all but the most frequently accessed views in a site like gaf.com end up being recompiled every time they are accessed. But if you put them in a project the compiled versions just need to be loaded from the dll if it's not already in memory (yes code can be garbage collected too, but less often). Loading that from the dll is 10 - 100 times faster (that's from the Razor Generator project's site - I didn't verify it myself, but it sounds reasonable).