When using the mini profiler, does this mean production code will be 'littered' with using blocks?
using (profiler.Step("Set page title"))
{
ViewBag.Title = "Home Page";
}
I guess if it is 1-off testing I could remove it, but usually you want to keep these in the codebase for constant profiling.
Developers have many tools they can use to profile web applications and find the performance bottlenecks. MiniProfiler is one such tool — a simple yet powerful tool for profiling web applications. MiniProfiler helps you detect slow running queries, slow server response times, and more.
MiniProfiler is a very lightweight, easy to use profiling library for ASP.Net applications which can profile dotnet application during runtime without change to the environment and effect on the application.
That is actually a bad example - you wouldn't normally profile something trivial.
Ultimately, it is elective what you want to profile. There's a hook for things like ADO.NET, but if you want it to profile things outside of this, yes: you need to give it a hand.
Re "littered", well, that is subjective. And the best approach is usually to limit the instrumentation to very high level operations, and then only zoom in with more granular operations as you find you need to (due to an identified problem spot); for example, you might have:
...
using(profiler.Step("Refresh customer"))
{
// ...
}
...
and then only when you find that taking 1800ms zoom in:
...
using(profiler.Step("Refresh customer"))
{
using(profiler.Step("Query LDAP"))
{ ... }
using(profiler.Step("Query primary customer DB"))
{ ... }
using(profiler.Step("Query aux db"))
{ ... }
using(profiler.Step("Print, scan, and OCR"))
{ ... }
}
...
There is also an .Inline(...)
method for individual commands.
Whether or not you think this is "littering":
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With