DOT

VVM

 DOCS

Version: |

MiniProfiler

This feature is available in DotVVM 1.1.5 and higher.

MiniProfiler is a library and UI for profiling your application. By letting you see where your time is spent, which queries are run, and any other custom timings you want to add. It helps you debug issues and optimize performance.

MiniProfiler was designed by the team at Stack Overflow and is extensively used in production by their team.

DotVVM supports this library and tracks some additional metrics which it collects during the processing of an HTTP request.

You can display the collected DotVVM metrics by adding the MiniProfiler Widget to a dothtml page:

DotVVM metrics in MiniProfiler

It is also possible to view the data traced in previous HTTP requests:

List of traced HTTP requests with details

MiniProfiler is capable of profiling other 3rd party services, e.g. Entity Framework and Redis.

Getting Started

MiniProfiler installation and configuration differs for ASP.NET Core and OWIN. You can find the details for extended configuration in the MiniProfiler documentation.

For both ASP.NET Core and OWIN, you can use the MiniProfilerWidget, which is a DotVVM control with many options like MaxTraces, Position, StartHidden etc.:

    <dot:MiniProfilerWidget Position="Right" ShowTrivial="true" StartHidden="true" />

ASP.NET Core

Be aware that MiniProfiler for ASP.NET Core is currently in alpha pre-release version.

  1. Run the following commands in the Package Manager Console window:
Install-Package MiniProfiler.AspNetCore -IncludePrerelease
Install-Package DotVVM.Tracing.MiniProfiler.AspNetCore
  1. Next, you can register the MiniProfiler integration into DotVVM request tracing in the ConfigureServices method this way:
services.AddDotVVM(options =>
{
    options.AddMiniProfilerEventTracing();
});
  1. As the last step, you need to add the MiniProfiler middleware before app.UseDotVVM<DotvvmStartup>():
public void Configure(IApplicationBuilder app, IMemoryCache cache)
{
    ...

    app.UseMiniProfiler(new MiniProfilerOptions
    {
        // Path to use for profiler URLs
        RouteBasePath = "~/profiler",

        // (Optional) Control storage
        Storage = new MemoryCacheStorage(cache, TimeSpan.FromMinutes(60)),
    });
    
    app.UseDotVVM<DotvvmStartup>();
    ...
}
  • To see it in action, you can simply navigate to ~/profiler/results-index and view profiled HTTP requests.

To see more information about the MiniProfiler configuration in ASP.NET Core project see the MiniProfiler for ASP.NET Core Documentation page.

We have a sample application to show how MiniProfiler can be used with ASP.NET Core.


Getting Started on OWIN

  1. Either use the NuGet UI to install MiniProfiler and DotVVM.Tracing.MiniProfiler.Owin, or use the following commands in the Package Manager Console window:
Install-Package MiniProfiler
Install-Package DotVVM.Tracing.MiniProfiler.Owin
  1. Register the DotVVM request tracing in the ConfigureServices method this way:
var dotvvmConfiguration = app.UseDotVVM<DotvvmStartup>(applicationPhysicalPath, options: options =>
{
    options.AddMiniProfilerEventTracing();
});
  • To see it in action, you can simply navigate to ~/mini-profiler-resources/results-index and view profiled HTTP requests.

You can change MiniProfiler default setting as you would do without DotVVM integration, for example:

StackExchange.Profiling.MiniProfiler.Settings.RouteBasePath = "~/profiler";
Next Chapter



Suggestions


Help & Contribute

The documentation is maintained on GitHub.
We'll be happy if you edit the page and create a pull request.

Send message