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/



  • 相关阅读:
    如何进行函数式编程
    HTML文本格式化
    非模态对话框的创建及注意事项
    中国第一代程序员列传
    野指针
    缓冲区溢出攻击
    windows全部启动项
    HTML 样式
    Volatile关键字
    HTML基本标签
  • 原文地址:https://www.cnblogs.com/coce/p/6738021.html
Copyright © 2011-2022 走看看