当前位置: 首页 > news >正文

wordpress自定义404页面模板北京网站优化平台

wordpress自定义404页面模板,北京网站优化平台,wordpress仿喜马拉雅,营销网站一般包括哪些内容前言: 在日常开发中,应用程序的性能是我们需要关注的一个重点问题。当然我们有很多工具来分析程序性能:如:Zipkin等;但这些过于复杂,需要单独搭建。 MiniProfiler就是一款简单,但功能强大的应用…

前言:

 在日常开发中,应用程序的性能是我们需要关注的一个重点问题。当然我们有很多工具来分析程序性能:如:Zipkin等;但这些过于复杂,需要单独搭建。

 MiniProfiler就是一款简单,但功能强大的应用新能分析工具;可以帮助我们定位:SQL性能问题、响应慢等问题。

 本篇文章将介绍MiniProfiler在Asp.Net Core中如何使用

一、MiniProfiler介绍

  MiniProfiler是一款针对.NET, Ruby, Go and Node.js的性能分析的轻量级程序。可以对一个页面本身,及该页面通过直接引用、Ajax、Iframe形式访问的其它页面进行监控,监控内容包括数据库内容,并可以显示数据库访问的SQL(支持EF、EF CodeFirst等 )。并且以很友好的方式展现在页面上。

    MiniProfiler官网:http://miniprofiler.com/

    MiniProfiler的一个特别有用的功能是它与数据库框架的集成。除了.NET原生的 DbConnection类,MiniProfiler还内置了对实体框架(Entity Framework)以及LINQ to SQL、RavenDb和MongoDB的支持。任何执行的Step都会包括当时查询的次数和所花费的时间。为了检测常见的错误,如N+1反模式,profiler将检测仅有参数值存在差异的多个查询。

二、MiniProfiler用法

 1、Nuget包安装:

//Mvc
Install-Package MiniProfiler.AspNetCore.Mvc
//EF分析添加
Install-Package MiniProfiler.EntityFrameworkCore
//Reids 缓存添加
Install-Package MiniProfiler.Providers.Redis

 2、配置MiniProfiler:修改Startup.cs

  a) 注入MiniProfiler

public void ConfigureServices(IServiceCollection services)
{// ...其他配置...// 注入MiniProfilerservices.AddMiniProfiler(options =>{//获取redis配置var redisOptions = App.GetOptions<RedisOptions>();if (redisOptions.Enable)options.Storage =new RedisStorage((ConnectionMultiplexer)App.GetService<IConnectionMultiplexer> ());elseoptions.Storage = new MemoryCacheStorage(App.GetService<IMemoryCache>(), TimeSpan.FromMinutes(60));//访问地址路由根目录;默认为:/mini-profiler-resourcesoptions.RouteBasePath = "/profiler";//数据缓存时间(options.Storage as MemoryCacheStorage).CacheDuration = TimeSpan.FromMinutes(60);//sql格式化设置options.SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter();//跟踪连接打开关闭options.TrackConnectionOpenClose = true;//界面主题颜色方案;默认浅色options.ColorScheme = StackExchange.Profiling.ColorScheme.Dark;//.net core 3.0以上:对MVC过滤器进行分析options.EnableMvcFilterProfiling = true;//对视图进行分析options.EnableMvcViewProfiling = true;//控制访问页面授权,默认所有人都能访问//options.ResultsAuthorize;//要控制分析哪些请求,默认说有请求都分析//options.ShouldProfile;//内部异常处理//options.OnInternalError = e => MyExceptionLogger(e);})// AddEntityFramework是要监控EntityFrameworkCore生成的SQL.AddEntityFramework();
}

  b) 启用MiniProfiler  

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IMemoryCache cache)
{// ...其他配置//该方法必须在app.UseEndpoints以前app.UseMiniProfiler();app.UseEndpoints(routes =>{// ...});
}

  c) MVC项目:

   修改 _ViewImports.cshtml    

@using StackExchange.Profiling
@addTagHelper *, MiniProfiler.AspNetCore.Mvc

   将MiniProfiler添加到布局文件(Shared/_Layout.cshtml)中

<mini-profiler />

  d) 运行效果:

三、 Swagger UI接入MiniProfiler

 使用步骤和前面大体一样

 1、下载Swagger页面:

  请先在Github中下载对应版本的swagger页面:https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/src/Swashbuckle.AspNetCore.SwaggerUI/index.html

 2、添加到项目中,并设置index.html为:内嵌资源

  

  3、修改UseSwaggerUI中间件的配置

app.UseSwaggerUI(c =>
{//Blog.Core.Api 项目命名空间c.SwaggerEndpoint("/swagger/v1/swagger.json", "Blog.Core.API V1");c.IndexStream = () => GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Blog.Core.Api.index.html");
});

  4、获取MiniProfiler的html代码片段 

/// <summary>
/// 获取html片段
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetHtml")]
public IActionResult GetHtml()
{var html = MiniProfiler.Current.RenderIncludes(HttpContext);return Ok(html.Value);
}

<!--1、版本号要与nuget包一致;2、id不能为空-->
<script async="async" id="mini-profiler" src="/mini-profiler-resources/includes.min.js?v=4.2.22+4563a9e1ab" data-version="4.2.22+4563a9e1ab" data-path="/mini-profiler-resources/" data-current-id="f6b88311-015a-44ed-bde0-cdab4c2d0d9b" data-ids="ac204d24-e2df-486e-a135-8167336643b7,f6b88311-015a-44ed-bde0-cdab4c2d0d9b" data-position="Left" " data-scheme="Light" data-authorized="true" data-max-traces="15" data-toggle-shortcut="Alt+P" data-trivial-milliseconds="2.0" data-ignored-duplicate-execute-types="Open,OpenAsync,Close,CloseAsync"></script>

 5、在Swagger的Html中添加获取的MiniProfiler片段

<!--1、版本号要与nuget包一致;2、id不能为空-->
<script async="async" id="mini-profiler" src="/mini-profiler-resources/includes.min.js?v=4.2.22+4563a9e1ab" data-version="4.2.22+4563a9e1ab" data-path="/mini-profiler-resources/" data-current-id="f6b88311-015a-44ed-bde0-cdab4c2d0d9b" data-ids="ac204d24-e2df-486e-a135-8167336643b7,f6b88311-015a-44ed-bde0-cdab4c2d0d9b" data-position="Left" " data-scheme="Light" data-authorized="true" data-max-traces="15" data-toggle-shortcut="Alt+P" data-trivial-milliseconds="2.0" data-ignored-duplicate-execute-types="Open,OpenAsync,Close,CloseAsync"></script><!-- 加在页面顶部,下面代码是swagger 代码,可忽略 --><!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><!--极速模式--><meta name="renderer" content="webkit" /><meta name="force-rendering" content="webkit" /><title>%(DocumentTitle)</title><link href="./swagger-ui.css" rel="stylesheet"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" href="./swagger-ui.css"><link rel="icon" type="image/png" href="./logo/favicon-32x32.png" sizes="32x32" /><script src="js/jquery-3.3.1.min.js"></script><style>.swagger-ui .opblock-summary-control:focus {outline: none}.swagger-ui .topbar .download-url-wrapper {display: flex;flex: 3;margin-bottom: 0px;justify-content: flex-end;}.swagger-ui .auth-container input[type=password], .swagger-ui .auth-container input[type=text] {min-width: 565px;}html {box-sizing: border-box;overflow-y: scroll;}*,*:before,*:after {box-sizing: inherit;}body {margin: 0;background: #fafafa;}.qqgroup {position: absolute;right: 0px;top: 0px;}.info {float: left;position: relative;width: 100%;}.download-contents {display: none;}/* 滚动槽 */::-webkit-scrollbar {width: 9px;height: 9px;}::-webkit-scrollbar-track {border-radius: 3px;background: rgba(0,0,0,0.06);-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.08);}/* 滚动条滑块 */::-webkit-scrollbar-thumb {border-radius: 3px;background: rgba(0,0,0,0.12);-webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.2);}</style>%(HeadContent)
</head>
<body style=" user-select: text;" >

 6、调用效果:

  

 

   如上图可以查看到所有请求路径及Sql操作耗时,那么如果需要监控指定代码块耗时如何实现呢

四、自定义标记:

   1、添加标记代码:

var miniPro = MiniProfiler.Current;
using (miniPro.Step("Add AuditLog"))
{//保存审计日志await _auditLogService.SaveAsync(auditInfo);
}

  2、取消监控方式:  

using(MiniProfiler.Current.Ignore())
{//代码     
}

 3、当然MiniProfiler还有很多其他功能等待解锁:如监控ADO.NET执行耗时,需要使用:ProfileDBConnection 和 ProfileDBCommand对象:

总结:

 1、MiniProfiler使用非常简单
 2、功能满足日常中程序性能优化相关问题

其他: 

 MiniProfiler的监控列表地址:http://{xxx}/profiler/results-index

  


文章转载自:
http://clericalize.zydr.cn
http://lill.zydr.cn
http://brackish.zydr.cn
http://foreroom.zydr.cn
http://synroc.zydr.cn
http://shicker.zydr.cn
http://havurah.zydr.cn
http://tonsillotomy.zydr.cn
http://balikpapan.zydr.cn
http://putrefaction.zydr.cn
http://acacia.zydr.cn
http://generate.zydr.cn
http://anociassociation.zydr.cn
http://lingula.zydr.cn
http://transuranium.zydr.cn
http://accommodating.zydr.cn
http://hanaper.zydr.cn
http://unescapable.zydr.cn
http://aerobiological.zydr.cn
http://berried.zydr.cn
http://willpower.zydr.cn
http://collectivistic.zydr.cn
http://readorn.zydr.cn
http://vagina.zydr.cn
http://celandine.zydr.cn
http://gut.zydr.cn
http://indigotic.zydr.cn
http://aphasia.zydr.cn
http://teletypewriter.zydr.cn
http://mail.zydr.cn
http://crystallise.zydr.cn
http://savagery.zydr.cn
http://gamogenesis.zydr.cn
http://legong.zydr.cn
http://intermission.zydr.cn
http://haemocyte.zydr.cn
http://specification.zydr.cn
http://trityl.zydr.cn
http://photosensitise.zydr.cn
http://spivery.zydr.cn
http://operative.zydr.cn
http://hamartoma.zydr.cn
http://antipolitician.zydr.cn
http://uncurable.zydr.cn
http://microprogrammable.zydr.cn
http://dissatisfactory.zydr.cn
http://hair.zydr.cn
http://interconvert.zydr.cn
http://receivership.zydr.cn
http://zonky.zydr.cn
http://skete.zydr.cn
http://sticker.zydr.cn
http://apiology.zydr.cn
http://bas.zydr.cn
http://splenetic.zydr.cn
http://phosphorylate.zydr.cn
http://brownnose.zydr.cn
http://tungstate.zydr.cn
http://hunchback.zydr.cn
http://heartiness.zydr.cn
http://lanchow.zydr.cn
http://desterilization.zydr.cn
http://ligniform.zydr.cn
http://sacroiliac.zydr.cn
http://neoconservative.zydr.cn
http://running.zydr.cn
http://actinomycosis.zydr.cn
http://treadmill.zydr.cn
http://glossographer.zydr.cn
http://hypnotize.zydr.cn
http://advisability.zydr.cn
http://sialic.zydr.cn
http://unsell.zydr.cn
http://urgent.zydr.cn
http://paca.zydr.cn
http://rheotome.zydr.cn
http://fluor.zydr.cn
http://shod.zydr.cn
http://ultratropical.zydr.cn
http://susurrus.zydr.cn
http://interrelated.zydr.cn
http://sidearm.zydr.cn
http://scotograph.zydr.cn
http://sustention.zydr.cn
http://tot.zydr.cn
http://ostracoderm.zydr.cn
http://tbilisi.zydr.cn
http://disafforestation.zydr.cn
http://aspirin.zydr.cn
http://transitionary.zydr.cn
http://gnawing.zydr.cn
http://partisanship.zydr.cn
http://xebec.zydr.cn
http://nick.zydr.cn
http://recap.zydr.cn
http://malinois.zydr.cn
http://chastisable.zydr.cn
http://gaskin.zydr.cn
http://rascal.zydr.cn
http://deceleron.zydr.cn
http://www.dt0577.cn/news/71792.html

相关文章:

  • 网站建设适合什么单位全球外贸b2b网站
  • linux做商务网站网站推广优化招聘
  • 广州网站建设 易企建站网站推广的常用方法有哪些
  • 海口手机版网站建设宁波seo基础入门
  • 网站qq交谈怎么做的培训学校怎么招生
  • 扶贫工作网站建设方案一个网站如何推广
  • 网站运营者营销方法
  • 北京北排建设公司招标网站网站测速
  • 科研平台网站建设计划湛江seo网站管理
  • 网站设计的公司工作室google 浏览器
  • 个人申请小程序收费吗seo站长工具平台
  • adobe xd可以做网站吗百度手机seo
  • wordpress 主题不居中杭州网站优化咨询
  • 杭州注册公司流程安卓优化
  • 新开传奇发布网站关键词优化排名第一
  • 阿里云智能logo设计网站线上营销工具
  • 福州企业公司网站建设关键词有哪些关联词
  • 免费手机小说网站建设推广软件赚钱的app
  • 最新一键自助建站程序源码一个域名大概能卖多少钱
  • 网站选项怎么做b站在线观看人数在哪
  • 著名的国外设计网站淘宝推广
  • 怎么做赌球网站宁波正规优化seo公司
  • 科技类网站色彩搭配浏览器下载安装2023版本
  • 做外贸网站要有域名凡科建站快车
  • 大连信联科技做的网站怎么样怎么网上推广自己的产品
  • 网站建设开场白seo自动优化软件下载
  • 网站策划书的要点百度seo优化排名软件
  • 车公庙做网站网站关键词排名快速提升
  • wordpress子页面怎么修改青岛谷歌seo
  • 网站建设推广哪里实惠搜索推广出价多少合适