MiniProfiler in ASP.NET Core
To install
dotnet add package MiniProfiler.AspNetCore.Mvc
dotnet add package MiniProfiler.EntityFrameworkCore
To configurepublic void ConfigureServices(IServiceCollection services)
{
....
services.AddMiniProfiler(options => options.RouteBasePath = "/profiler").AddEntityFramework();
....
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseMiniProfiler();
/* Code removed for brevity. */
}
To access a list of all requests, navigate to/profiler/results-index
To profile methods in a class libray, add this nuget package MiniProfiler.AspNetCore
Wrap the piece of code like thisusing (MiniProfiler.Current.Step("InsertUpdateBillAsync"))
{
.....
}
To wrap a single lineawait MiniProfiler.Current.Inline(async () => await ProcessCommitteeAsync(bill.committee), "ProcessCommitteeAsync");
Comments
Post a Comment