.NET Core (Console Applications)
If you’d rather learn by example, sample apps are available. The .NET Core Console sample is here, with the important bits in Program.cs.
Installation and Configuration
- Install the NuGet Package: MiniProfiler.AspNetCore (There is no package for just .NET Core Console applications, see this GitHub issue)
- Either use the NuGet UI to install
MiniProfiler.AspNetCore
(which has all needed dependencies) - Or use the Package Manager Console:
- Either use the NuGet UI to install
Install-Package MiniProfiler.AspNetCore -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...
}
}
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:
Console.WriteLine(profiler.RenderPlainText());
// or for the active profiler:
Console.WriteLine(MiniProfiler.Current.RenderPlainText());