MiniProfiler for .NET Documentation Go to the repo

.NET (Console Applications)

If you’d rather learn by example, sample apps are available. The .NET Console sample is here, with the important bits in Program.cs.

Installation and Configuration

  • Install the NuGet Package: MiniProfiler
    • Either use the NuGet UI to install MiniProfiler (which has all needed dependencies)
    • Or use the Package Manager Console:
Install-Package MiniProfiler -IncludePrerelease
  • Edit your Program.cs to configure MiniProfiler and start profiling:
public static void Main()
    // Default configuration usually works for most, but override, you can call:
    // MiniProfiler.Configure(new MiniProfilerOptions { ... });

    var profiler = MiniProfiler.StartNew("My Profiler Name");
    using (profiler.Step("Main Work"))
        // Do some work...

Note that we’re using DefaultProfilerProvider here because we’re not in a web context, e.g. we don’t want profiles accessed via HttpContext.Items in a console application.

Viewing the results

To output the results you can do so from shared storage anywhere or in the simple console case you may just want some plain text output. To see the profiler tree rendered as simple text you can use:

// or for the active profiler: