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/



  • 相关阅读:
    第二章、Redis入门介绍
    最高的牛
    增减序列
    激光炸弹
    分形之城
    约数之和
    奇怪的汉诺塔
    费解的开关
    递归实现排列型枚举
    递归实现组合型枚举
  • 原文地址:https://www.cnblogs.com/coce/p/6738021.html
Copyright © 2011-2022 走看看