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.

Configure MiniProfiler

  1. Run the following commands in the Package Manager Console window:
Install-Package MiniProfiler.AspNetCore.Mvc
Install-Package DotVVM.Tracing.MiniProfiler.AspNetCore
  1. Next, you can register the MiniProfiler integration into DotVVM request tracing in the IDotvvmServiceConfigurator this way:
public void ConfigureServices(IDotvvmServiceCollection options)
  1. As the last step, you need to add the MiniProfiler services in the ConfigureServices method and the Miniprofiler middleware before app.UseDotVVM<DotvvmStartup>():
public void ConfigureServices(IServiceCollection services)
    services.AddMiniProfiler(options =>
        options.RouteBasePath = "/profiler";

public void Configure(IApplicationBuilder app)

To see it in action, you can simply navigate to ~/profiler/results-index and view profiled HTTP requests.

Check out the sample application to show how MiniProfiler can be used.

You can find the details for extended configuration in the MiniProfiler documentation.

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

View results

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

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

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

Profiling your own code

You can easily profile your code in order to measure the performance.

using (MiniProfiler.Current.Step("GetOrder"))
    return orderRepository.Get();

See the Profile code section in MiniProfiler documentation for more info.

See also