Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC URL generation performance
    primarykey
    data
    text
    <p>A little benchmark with ASP.NET MVC. Viewpage code:</p> <pre><code> public string Bechmark(Func&lt;string&gt; url) { var s = new Stopwatch(); var n = 1000; s.Reset(); s.Start(); for (int i = 0; i &lt; n; i++) { var u = url(); } s.Stop(); return s.ElapsedMilliseconds + " ms, " + ((s.ElapsedMilliseconds) / (float)n) + " ms per link&lt;br/&gt;"; } </code></pre> <p>View code:</p> <pre><code>&lt;%= Bechmark(() =&gt; Url.Action("Login", "Account")) %&gt; &lt;%= Bechmark(() =&gt; Url.Action("Login", "Account", new {username="bla", password="bla2", returnurl="blabla32", rememberme=false} )) %&gt; &lt;%= Bechmark(() =&gt; Html.BuildUrlFromExpression&lt;AccountController&gt;(a=&gt;a.ChangePassword("bla", "bla", "ya")) ) %&gt; </code></pre> <p>Running this on a typical Core2 notebook on the default new project template with ASP.NET MVC Beta yields these results:</p> <blockquote> <p>38 ms, 0,038 ms per link</p> <p>120 ms, 0,12 ms per link</p> <p>54 ms, 0,054 ms per link</p> </blockquote> <p>Running the same benchmark on a production project with about 10 controllers that have all in all around 100 methods and 30 routing table entries, the performance degrades greatly for the expression-based method:</p> <blockquote> <p>31 ms, 0,031 ms per link</p> <p>112 ms, 0,112 ms per link</p> <p>450 ms, 0,45 ms per link</p> </blockquote> <p>We use this method quite a lot (maintainability) and doing some performance benchmarking, this degrades the performance of the site greatly - pages quickly contain around 30 or more of such links, that means 10ms of additional overhead on a single page. Even 0.112ms per an URL is around 4ms of pure CPU overhead.</p> <p>It should be noted that performance of all the three URL generation calls between MVC Preview 3 and Beta (released yesterday) got improved by a factor of 5.</p> <p>Stack Overflow is supposedly powered by the same framework, how have you guys tackled this scaling problem? Liberal caching of the front page (lots of links) and pre-rendered controls?</p> <p>Any other production websites in ASP.NET MVC with performance issues or some good tips?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload