Tag: mvc mini profiler

使用MiniProfiler直接调用ADO.net

对于那些在C#和剖析中极客的人来说,这个问题将是愚蠢的。 我是c#的新手(基本上是一个c ++开发人员)。 如果它使用dbproviderfactory ,我可以分析数据库查询,但是当直接使用它时,我无法分析ado.net调用(原始SqlConnection和SqlCommand )。 我遇到了Miniprofiler代码,他们也可以直接调用ADO.net调用。 我只是不知道如何使用它(将其集成到我的探查器中)。 我的代码是 SqlConnection myConn = new SqlConnection(@”Server=192.168.23.99;Initial Catalog=cat1;User ID=user21;Password=userpwd”); SqlCommand myCommand = new SqlCommand(“select * from table1”, myConn); SqlDataReader dataReader; System.Threading.Thread.Sleep(5000); try { myConn.Open(); dataReader = myCommand.ExecuteReader(); GridView1.DataSource = dataReader; GridView1.DataBind(); dataReader.Close(); myCommand.Dispose(); myConn.Close(); } catch (System.Exception ex) { Response.Write(ex.ToString()); } 当执行上面的代码时,将如何调用MiniProfiler中的类? 当我的Web应用程序调用SqlCommand(..)时,如何调用这些类(希望类名是SimpleProfiledDbCommand )。 需要更好地澄清这一点。

MVC Miniprofiler,所有的额外时间去了哪里?

我正在使用MVC Mini Profiler来查找为什么非常基本的页面渲染速度很慢:在本地运行时,只需要700毫秒来渲染12kb的html。 它表明所有的动作都是微不足道的(除非我点击show琐事按钮,它们甚至都没有显示),最长只有2.4毫秒。 但是,对于这些所谓的微不足道的行为,“从开始的时间”数字会跳跃大约100毫秒。 什么在这个时候使用? 是否有miniprofiler选项可以帮助显示这个时间的使用位置? 编辑:额外的时间可能发生在MVC管道 – 有什么方法来描述这个? 编辑#2:尝试使用true预编译视图并没有改善性能

如何隐藏miniprofiler?

我正在使用MVC Mini分析器来检查我的应用程序的特定部分的速度,并希望将其保留在那里以防万一发生以后的事情,我可能需要检查“出了什么问题”。 它不是一个完整的日志集,但它非常方便地知道什么使页面花了很长时间。 因此,我的目标是隐藏它并仅在请求带有特定参数时才对其进行配置。 但是,我的尝试都没有像我期望的那样奏效。 这已经完成了不在屏幕上显示它的技巧(视图中的代码): @if (Request.QueryString.AllKeys.Contains(“showProfiler”)) { @MvcMiniProfiler.MiniProfiler.RenderIncludes() } 这是接近的尝试。 正确地隐藏迷你探查器信息,但是在我显示它的那一刻,它描述了自我停止显示它以来的所有内容。 所以,假设我描述了我的页面,需要3秒钟。 我删除了查询参数并再次加载页面三次。 我再次添加我的参数,我看到4组配置文件信息。 这意味着它会记录所有内容,我想知道它是否会给内存带来问题。 尝试不再发生这种情况: 尝试1: protected void Application_BeginRequest() { if (Request.QueryString.AllKeys.Contains(“showProfiler”)) { MiniProfiler.Start(); } } 尝试2: protected void Application_EndRequest() { MiniProfiler.Stop(!Request.QueryString.AllKeys.Contains(“showProfiler”)); } 尝试3: protected void Application_EndRequest() { MiniProfiler.Stop(true); } 这些都没有奏效。 有任何想法吗?

如何在entity framework4.1中使用mvc-mini-profiler

我试图使用mvc-mini-profiler与MVC3并继续得到以下错误 无法确定连接类型为“MvcMiniProfiler.Data.ProfiledDbConnection”的提供程序名称 下面是我用来尝试和实现我的Context的代码。 DbConnection conn = new MySqlConnection( ConfigurationManager.ConnectionStrings[“ConnString”].ConnectionString); var profiledConnection = MvcMiniProfiler.Data.ProfiledDbConnection.Get(conn); return new DB(profiledConnection); 这是DB Context Class。 public class DB:DbContext, Stats.Data.IDB { public DB(DbConnection conn) : base(conn, true) { }…

MvcMiniProfiler无法转换EFProfiledDbConnection类型的对象

我正在尝试将MvcMiniProfiler集成到我的asp.net mvc +实体framewok项目中。 第一次Web请求时一切正常,但是在其他请求中给出了exception。 我的项目是 MVC 3 entity framework4.1(DatabaseFirst + POCO Generator DbContext) MvcMiniProfiler.dll 1.9.0.0 MvcMiniProfiler.EntityFramework.dll 1.9.1.0 我从Nu-Get安装了MvcMiniProfiler 下面添加到global.asax protected void Application_BeginRequest() { if (Request.IsLocal) { MvcMiniProfiler.MiniProfiler.Start(); MiniProfilerEF.Initialize(); } } 下面添加到web.config 我得到了这个例外 System.InvalidCastException was unhandled by user code Message=Unable to cast object of type ‘MvcMiniProfiler.Data.EFProfiledDbConnection’ to type ‘System.Data.SqlClient.SqlConnection’. Source=System.Data StackTrace: at System.Data.SqlClient.SqlCommand.set_DbConnection(DbConnection value) at System.Data.Common.DbCommand.set_Connection(DbConnection […]

MvcMiniProfiler结果请求在Asp.Net MVC应用程序中提供404

我试图在我的Asp.Net MVC应用程序中使用MvcMiniProfiler。 我安装了最新的NuGet包,并将维基页面中的所有代码添加到Application_BeginRequest() , Application_AuthenticateRequest()和我的视图中。 加载页面后,所有迷你探查器的javascript文件都被包含在内并从服务器上正确下载,但当它尝试获取结果时Chrome显示: GET http://localhost:59269/mini-profiler-results?id=59924d7f-98ba-40fe-9c4a-6a163f7c9b08&popup=1 404 (Not Found) 我假设这是因为没有设置MVC的路由以允许/mini-profiler-results但是我找不到办法做到这一点。 查看Google代码页,他们的示例应用程序的Global.asax.cs文件经历了多次更改,一次使用MvcMiniProfiler.MiniProfiler.RegisterRoutes() ,第二次使用MvcMiniProfiler.MiniProfiler.Init() ,第三次什么都不做的风格。 前面提到的两个函数不存在,所以我假设它们已被逐步淘汰。 此时我不确定如何修复此错误并在我的应用程序中使用分析器。 有任何想法吗? 我的Global.Asax.cs文件如下所示: public class Global : System.Web.HttpApplication { protected void Application_BeginRequest() { MvcMiniProfiler.MiniProfiler.Start(); } protected void Application_AuthenticateRequest(Object sender, EventArgs e) { // Only show profiling to admins if (!Roles.IsUserInRole(Constants.AdminRole)) MvcMiniProfiler.MiniProfiler.Stop(discardResults: true); } protected void Application_Start(object sender, EventArgs e) […]

将MVC迷你探查器时序转换为异步任务

我在一个页面中运行了一个长时间的SQL查询,我通过使用异步任务来加速: using System.Threading.Tasks; … var asyncTask = new Task( () => { using (var stepAsync = MiniProfiler.Current.Step(“Async!”)) { // exec long running SQL } }); asyncTask.Start(); // do lots of other slow stuff ResultClass result; using (var stepWait = MiniProfiler.Current.Step(“Wait for Async”)) { result = asyncTask.Result; } (注意,一旦C#5出现async并await ,这种语法会更好) 当使用MVC迷你探查器时,我得到了“等待异步”的时间,但我无法得到“异步!”的时间。 步。 有没有办法将这些结果(可能只是SQL时序)放入已完成页面的跟踪中? 更新 我找到了一种方法来让探查器步骤进入异步方法: var […]

在不创建数据库的情况下,将Mini-Profilier与EF 4.3和MVC 4配合使用

我有一个问题,我们在现有数据库中使用EF 4.3 Code First。 我想使用带有EF的Mini-Profiler并打电话 MvcMiniProfiler.MiniProfilerEF.Initialize(); 但是,由于我们实际上并未创建任何表,因此dbo .__ MigrationHistory和dbo.EdmMetadata表不存在。 分析器最终崩溃,因为它们不存在。 有没有办法让探查器忽略这些EF Code First特定的表? 谢谢! 编辑: 这些是我得到的例外:(它们分开来) Invalid object name ‘dbo.__MigrationHistory’. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at […]

MiniProfiler没有出现在asp.net MVC上

我把它添加到我的Global.asax.cs: protected void Application_BeginRequest() { if (Request.IsLocal) { MiniProfiler.Start(); } } protected void Application_EndRequest() { MiniProfiler.Stop(); } 我补充道 @MiniProfiler.RenderIncludes() 就在_Layout.cshtml中的标记下面。 在我的控制器中我正在使用: public class HomeController : Controller { public ActionResult Index() { 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 […]

Mini MVC profiler:似乎显示每个静态资源的配置文件时间

我刚刚开始使用mvc-mini-profiler( http://code.google.com/p/mvc-mini-profiler/ ),我觉得它很棒。 但是,我在使用它时会遇到一些奇怪的行为。 我有一个在IIS7.5上运行的ASP.NET Webforms站点,出于某种原因,当我加载启用了探查器的页面时,我不仅获得了aspx页面的时间测量,而且还得到了随机css和页面上的js资源。 aspx配置文件正常工作,SQL查询也正确分析。 但是,如图所示,我还得到了一堆其他结果,这些结果似乎是静态CSS和JS文件的结果。 据我所知,这些是由IIS静态提供的,因此甚至不应该为这些调用探查器代码。 我的Global.asax的相关部分是: protected void Application_BeginRequest() { MiniProfiler profiler = null; // might want to decide here (or maybe inside the action) whether you want // to profile this request – for example, using an “IsSystemAdmin” flag against // the user, or similar; this could also all be […]