Q: How do I calculate the total time it takes to render an MVC page and display the time on the master page.
In Asp.net Web Form I created a Base page class like so:
Go into your web.config and make sure you have...
Then you can goto http://.../trace.axd and see every request made.
Then you want to look under the From First(s) column and the very last one is the time it took to render the page (server side).
Example...
aspx.page End Render 0.06121112 0.005297
61.2 ms to render the page.
If you're looking to time code itself or you want to manually do some diagnostics you want to use the System.Diagnostics.Stopwatch class not DateTime.
Stopwatch sw = Stopwatch.StartNew();
...
sw.Stop();
Trace.Write(sw.ElapsedMilliseconds);