/// <summary> /// Asynchronously stops the current profiling session. /// </summary> /// <param name="profiler">The <see cref="MiniProfiler"/> to stop.</param> /// <param name="discardResults"> /// When true, clears the <see cref="MiniProfiler.Current"/>, allowing profiling to /// be prematurely stopped and discarded. Useful for when a specific route does not need to be profiled. /// </param> public Task StoppedAsync(MiniProfiler profiler, bool discardResults) { Stopped(profiler, discardResults); return(Task.CompletedTask); }
/// <summary> /// Starts a new profiling session. /// </summary> /// <param name="profilerName">The name for the started <see cref="MiniProfiler"/>.</param> /// <param name="options">The options to use for this profiler, including all downstream commands.</param> public MiniProfiler Start(string profilerName, MiniProfilerBaseOptions options) => _profiler = new MiniProfiler(profilerName, options);
/// <summary> /// Returns an <see cref="Timing"/> (<see cref="IDisposable"/>) that will time the code between its creation and disposal. /// Will only save the <see cref="Timing"/> if total time taken exceeds <paramref name="minSaveMs" />. /// </summary> /// <param name="profiler">The current profiling session or <c>null</c>.</param> /// <param name="name">A descriptive name for the code that is encapsulated by the resulting Timing's lifetime.</param> /// <param name="minSaveMs">The minimum amount of time that needs to elapse in order for this result to be recorded.</param> /// <param name="includeChildren">Should the amount of time spent in child timings be included when comparing total time /// profiled with <paramref name="minSaveMs"/>? If true, will include children. If false will ignore children.</param> /// <returns></returns> /// <remarks>If <paramref name="includeChildren"/> is set to true and a child is removed due to its use of StepIf, then the /// time spent in that time will also not count for the current StepIf calculation.</remarks> public static Timing StepIf(this MiniProfiler profiler, string name, decimal minSaveMs, bool includeChildren = false) { return(profiler?.StepImpl(name, minSaveMs, includeChildren)); }
/// <summary> /// Returns an <see cref="IDisposable"/> that will ignore profiling between its creation and disposal. /// </summary> /// <remarks> /// This is mainly useful in situations where you want to ignore database profiling for known hot spots, /// but it is safe to use in a nested step such that you can ignore sub-sections of a profiled step. /// </remarks> /// <param name="profiler">The current profiling session or null.</param> /// <returns>the profile step</returns> public static IDisposable Ignore(this MiniProfiler profiler) => profiler != null ? new Suppression(profiler) : null;
/// <summary> /// Returns an <see cref="Timing"/> (<see cref="IDisposable"/>) that will time the code between its creation and disposal. /// </summary> /// <param name="profiler">The current profiling session or null.</param> /// <param name="name">A descriptive name for the code that is encapsulated by the resulting Timing's lifetime.</param> /// <returns>the profile step</returns> public static Timing Step(this MiniProfiler profiler, string name) => profiler?.StepImpl(name);