I like the partial parts in Razor views. This makes the code nice and clean. But is there a significant cost to using partial data? I created a simple test. He shows that using partial contractions is much slower.
test.cshtml:
@{ var stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); for(var i=0; i<1000; i++) { var str = "my string #" + i; @Html.Partial("_MyPartial",str)
_MyPartial.cshtml:
@Model
The partial execution code is 340 ms, and the inline @str code is 0 or 1 ms. It really shockes me, because it means that I have to get rid of all my pretty particles, at least those in cycles.
If someone wants to confirm or criticize my experiment, you are very welcome.
source share