zoukankan      html  css  js  c++  java
  • 使用MiniProfiler检测页面性能

    1.引入nuget包

    PM> Install-Package MiniProfiler
    

    2.配置界面

    @using StackExchange.Profiling;
    <head>
     ..
    </head>
    <body>
      ...
      @MiniProfiler.RenderIncludes()
    </body>
    

    3.配置Global.asax.cs

    using StackExchange.Profiling;
    ...    
    protected void Application_BeginRequest()
    {
        if (Request.IsLocal)
        {
            MiniProfiler.Start();
        } 
    }
    protected void Application_EndRequest()
    {
        MiniProfiler.Stop();
    }
    
    protected void Application_Start()
    {
    //EF监控配置 MiniProfilerEF6.Initialize(); }

    4.监控具体代码

    using StackExchange.Profiling;
    ...
    var profiler = MiniProfiler.Current; // it's ok if this is null
    using (profiler.Step("Set page title"))
    {
    	ViewBag.Title = "Home Page";
    }
    using (profiler.Step("Doing complex stuff"))
    {
    	using (profiler.Step("Step A"))
    	{ // something more interesting here
    		Thread.Sleep(100);
    	}
    	using (profiler.Step("Step B"))
    	{ // and here
    		Thread.Sleep(250);
    	}
    }
    

    5.视图不现实监控结果

    <system.webServer>
      ...
      <handlers>
        <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
      </handlers>
    </system.webServer>
    

      

    官网介绍:http://miniprofiler.com/



  • 相关阅读:
    HDU 1106 排序
    strtok函数()
    HDU 2187汶川地震
    HDU 1716 排列2
    Rightmost Digit
    Text Reverse
    快速幂
    插入排序的一个应用-调整负数在前,正数在后,原来相对位置不变
    cuda 5.0配置vs2008+Visual Assist X +安装问题解决
    vc 热键、组合键的用法
  • 原文地址:https://www.cnblogs.com/coce/p/6738021.html
Copyright © 2011-2022 走看看