Exemple #1
0
 /// <summary>
 /// Wraps <paramref name="selector"/> in a <see cref="Step"/> call and executes it, returning its result.
 /// </summary>
 /// <param name="profiler">The current profiling session or null.</param>
 /// <param name="selector">Method to execute and profile.</param>
 /// <param name="name">The <see cref="Timing"/> step name used to label the profiler results.</param>
 /// <returns></returns>
 public static T Inline <T>(this MiniProfiler profiler, Func <T> selector, string name)
 {
     if (selector == null)
     {
         throw new ArgumentNullException("selector");
     }
     if (profiler == null)
     {
         return(selector());
     }
     using (profiler.StepImpl(name))
     {
         return(selector());
     }
 }
Exemple #2
0
 /// <summary>
 /// Returns an <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 IDisposable's lifetime.</param>
 /// <param name="level">This step's visibility level; allows filtering when <see cref="MiniProfiler.Start"/> is called.</param>
 public static IDisposable Step(this MiniProfiler profiler, string name, ProfileLevel level = ProfileLevel.Info)
 {
     return(profiler == null ? null : profiler.StepImpl(name, level));
 }