阅读http://code.google.com/p/mvc-mini-profiler/上的文章
对于java web应用程序,这样的任何开源分析器都可用吗?
有人开始将这个端口移植到Java环境中吗?
谢谢.
我在让MiniProfiler向我展示报告方面遇到了问题.我只是在Dev环境中,它应该一直显示它.添加?pp=help确实会显示帮助页面.在tmp/miniprofile中,有大量的mp_timers_文件.显然有些事情发生在那里.
起初我认为这是一个奇怪的CSS问题,就像我的导航栏覆盖它一样.我尝试加载没有CSS的页面,MiniProfile框仍然没有出现.
如果重要,我没有before_filter设置.但是,当我使用他们的文档中的简单文件时,它没有任何帮助.
我一直在玩MVC-Mini-Profiler,发现它非常有用.但是,在我追踪的所有页面上,我都会收到重复查询的报告,如下所示.
但是,我已经在SQL Server Profiler中跟踪了查询,毫无疑问它只能访问数据库一次.
我在这里错过了一个概念还是我错误地设置了它?对于有类似问题的人,我一直在搜索高低,没有运气,所以我怀疑是否存在错误.

http://localhost:27941/clubs
T+175.2 ms
Reader
13.6 ms
utePageHierarchy Execute System.Collections.Generic.IEnumerable<T>.GetEnumerator GetResults Execute ExecuteStoreCommands
SELECT
[Extent1].[TeamId] AS [TeamId],
[Extent1].[Title] AS [Title],
[Extent1].[TitleShort] AS [TitleShort],
[Extent1].[LogoImageId] AS [LogoImageId],
[Extent1].[Slug] AS [Slug],
(SELECT
COUNT(1) AS [A1]
FROM [dbo].[Athletes] AS [Extent2]
WHERE [Extent1].[TeamId] = [Extent2].[TeamId]) AS [C1]
FROM [dbo].[Teams] AS [Extent1]
WHERE 352 = [Extent1].[CountryId]
http://localhost:27941/clubs
T+175.4 ms
DUPLICATE Reader
13.4 ms
utePageHierarchy Execute System.Collections.Generic.IEnumerable<T>.GetEnumerator GetResults Execute ExecuteStoreCommands
SELECT
[Extent1].[TeamId] AS [TeamId],
[Extent1].[Title] AS [Title],
[Extent1].[TitleShort] AS [TitleShort],
[Extent1].[LogoImageId] AS …Run Code Online (Sandbox Code Playgroud) 我相信mvc mini profiler有点'上帝送'
我已将其合并到一个针对Azure平台的新MVC项目中.我的问题是 - 如何处理跨服务器(角色实例)障碍的分析?
这有可能吗?
我在页面中运行了一个长时间运行的SQL查询,我使用异步任务加速了:
using System.Threading.Tasks;
...
var asyncTask = new Task<ResultClass>(
() =>
{
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;
}
Run Code Online (Sandbox Code Playgroud)
(请注意,这句法将是一个要好很多,一旦C#5出来与async和await)
当使用MVC mini profiler时,我得到了"等待异步"的时间,但我无法得到"异步!"的时间.步.
有没有办法将这些结果(可能只是SQL时间)纳入已完成页面的跟踪中?
更新
我找到了一种方法来让探查器步骤进入异步方法:
var asyncTask = new Task<ResultClass>(
profiler =>
{
using (var step = (profiler as MiniProfiler).Step("Async!"))
{
// exec long running SQL
} …Run Code Online (Sandbox Code Playgroud) 无法将类型为"MvcMiniProfiler.Data.EFProfiledDbConnection"的对象强制转换为"System.Data.SqlClient.SqlConnection".
我正在尝试升级到MvcMiniProfiler 1.9.0,当我调用MiniProfilerEF.Initialize()时我会继续这样做.我已经删除了system.data配置部分.我不知道我做错了什么.我已经按照网站上的步骤进行了操作,但也许我错过了什么?
我首先使用EF代码4.1并且我将我的connectionstring的名称传递给构造函数以创建我的datacontext.
Web Activator
using Project.Web.App_Start;
using WebActivator;
[assembly: PreApplicationStartMethod(typeof(MiniProfiler), "Start")]
namespace Project.Web.App_Start {
public class MiniProfiler {
public static void Start()
{
if (Eco.Environment.IsDevelopment) {
MiniProfilerEF.Initialize();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
StructureMap注册表:
using Project.Domain.Repositories;
using StructureMap.Configuration.DSL;
namespace Project.Web.DependencyResolution.Registries {
public class RepositoriesRegistry : Registry {
public RepositoriesRegistry() {
For<IProjectDataContext>().HybridHttpOrThreadLocalScoped().Use(() => new ProjectDataContext(Eco.Database.Name));
}
}
}
Run Code Online (Sandbox Code Playgroud)
DataContext构造函数:
public ProjectDataContext(string nameOrConnectionString)
: base(nameOrConnectionString) {
Active = new Active(this);
}
Run Code Online (Sandbox Code Playgroud)
我从配置中删除了system.data dataproviders,因为文档说我只需要调用MiniProfilerEF.Initialize().
**更新
以前在1.7 MvcMiniProfiler中我必须设置Database.DefaultConnectionFactory属性,但我删除了它.Database.DefaultConnectionFactory总是以SqlConnectionFactory的形式返回,不应该是ProfiledConnectionFactory或类似的东西吗?
我在Web表单应用程序中有一个现有的数据库连接功能,我想与迷你探查器集成.我在应用程序上安装并运行了迷你探查器,但我似乎无法正确连接数据库部分.下面是我们连接到db的代码的一部分.
public override IEnumerable<IDataRecord> Execute()
{
using( SqlConnection conn = new SqlConnection( ConnectionString ) ) {
using( SqlCommand command = new SqlCommand( CommandText, conn ) ) {
command.CommandType = SQLCommandType;
foreach( SqlParameter p in ParamsToAdd ) {
command.Parameters.Add( p );
}
conn.Open();
SqlDataReader rdr;
try {
rdr = command.ExecuteReader();
} catch( Exception ex ) {
//log error
}
using( rdr ) {
while( rdr.Read() ) {
yield return (IDataRecord)rdr;
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我可以像这样轻松地绕过ExecuteReader():
using( MiniProfiler.Current.Step( command.CommandText …Run Code Online (Sandbox Code Playgroud) 我的web.config文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<system.web>
<customErrors mode="On" redirectMode="ResponseRewrite">
<error statusCode="500" redirect="~/Content/ErrorPages/500.aspx" />
<error statusCode="404" redirect="~/Content/ErrorPages/404.aspx" />
</customErrors>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
<httpModules>
<add type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" name="UrlRewriter" />
</httpModules>
</system.web>
<rewriter configSource="Config\URLRewrites.config" />
<appSettings configSource="Config\Settings.config" />
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<httpErrors errorMode="Custom">
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/Content/ErrorPages/404.aspx" responseMode="ExecuteURL" />
<error statusCode="500" path="/Content/ErrorPages/500.aspx" responseMode="ExecuteURL" />
</httpErrors>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRewriter" />
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" …Run Code Online (Sandbox Code Playgroud) 有时候使用miniprofiler时,只有一些你不关心的请求.在我的情况下,我不太关心信号器,umbraco ping,以及当我想知道用户是否闲置时提出的一些请求.
为了避免miniprofiler在这些类型的请求中使用能量(并提供结果),我将以下代码添加到我的global.asax.cs文件中:
protected void Application_BeginRequest()
{
if (
(Request.IsLocal || Request.UserHostAddress == "37.49.143.197")
&& !(Request.RawUrl.Contains("/signalr/")
|| Request.RawUrl.Contains("/idle/verify")
|| Request.RawUrl.Contains("/idle/interaction")
|| Request.RawUrl.Contains("/umbraco/ping")
)
)
{
MiniProfiler.Start();
}
}
Run Code Online (Sandbox Code Playgroud)
看到我仍然收到包含给定字符串的URL的结果,我稍后在应用程序生命周期中进行了此检查,试图消除我可以看到的不必要的结果.
protected void Application_ProcessRequest()
{
if (Request.RawUrl.Contains("/signalr/")
|| Request.RawUrl.Contains("/idle/verify")
|| Request.RawUrl.Contains("/idle/interaction")
|| Request.RawUrl.Contains("/umbraco/ping")
)
{
MiniProfiler.Stop(discardResults: true);
}
}
Run Code Online (Sandbox Code Playgroud)
但即使我已经这样做了,我仍然收到了不想要的结果.有谁知道这是怎么回事,我在这里做错了什么?
应该注意的是,因为我使用Umbraco作为我的基础,我正在使用MiniProfiler 2.1.0并且我开始我的Global.asax.cs文件,如下所示:
public class MvcApplication : UmbracoApplication
{
protected override void OnApplicationStarted(object sender, EventArgs e)
{
// Setup profiler for Controllers via a Global ActionFilter
GlobalFilters.Filters.Add(new ProfilingActionFilter()); …Run Code Online (Sandbox Code Playgroud) 我似乎无法从MiniProfiler获得任何结果。
我可以看到 XHR POST 返回/mini-profiler-resources/results404。chrome 请求检查器为我提供了一个标准服务器 404 页面。
对同一 URL 的 GET 也会返回 404,但有一条消息说“没有找到指定 id 的结果”(我确实在查询字符串中添加了 id)。
当我查看/mini-profiler-resources/results-index它时,它只是给了我一个空表,其中包含字段标题 - 名称、开始、sql、持续时间等。
我已经尝试了一些事情 - 详细信息如下 - 在这个阶段我不知道下一步可以尝试什么。任何调试此问题的指针或建议将不胜感激。
MVC4 也适用于 MVC5。这个项目就是哪个。
protected void Application_Start()
{
MiniProfilerEF6.Initialize();
MiniProfiler.Settings.Results_List_Authorize = IsUserAllowedToSeeMiniProfilerUI;
MiniProfiler.Settings.MaxJsonResponseSize = int.MaxValue;
Database.SetInitializer<ApplicationDbContext>(null);
GlobalFilters.Filters.Add(new ProfilingActionFilter());
var copy = ViewEngines.Engines.ToList();
ViewEngines.Engines.Clear();
foreach (var item in copy)
{
ViewEngines.Engines.Add(new ProfilingViewEngine(item));
}
}
protected void Application_BeginRequest(Object source, EventArgs e)
{
if (Request.IsLocal) …Run Code Online (Sandbox Code Playgroud) c# ×4
asp.net-mvc ×2
.net ×1
asp.net ×1
asynchronous ×1
azure ×1
java ×1
profiler ×1
sql ×1
sql-server ×1
umbraco ×1