Timing ASP.NET Page load
<p>What is the best way to measure the code run time in ASP.NET page?</p>

<p>Here is my code, trying to time the page load and writing to log. </p>

<pre><code>   private Stopwatch PageTimer = null;

    protected void Page_Init(Object Src, EventArgs E)
    {
        if (!IsPostBack)
        {
            PageTimer = new Stopwatch();
            PageTimer.Start();


        }
    }

    protected override void OnPreRender(EventArgs e)
    {
        if (!IsPostBack)
        {
            PageTimer.Stop();
            Logger.SectionEnd("PageTimer", PageTimer, "", true);
        }
        base.OnPreRender(e);
    }
</code></pre>
