예제 #1
0
        private static async Task ProfileAsync(int id)
        {
            var profiler = ProfilerFactory.GetCurrentProfiler();

            profiler.Start();

            await OperationAsync($"session_{id}", 0).ConfigureAwait(false);

            profiler.Stop();
        }
예제 #2
0
        private static async Task OperationAsync(string namePrefix, int level)
        {
            var profiler = ProfilerFactory.GetCurrentProfiler();

            for (var k = 0; k < 10; k++)
            {
                var name = $"{namePrefix}_{k}";

                using (profiler.Profile(new ProfileOperationSpecification(name)))
                {
                    if (level < 5 && RandomizationExtensions.Random.NextBool())
                    {
                        await OperationAsync(name, level + 1).ConfigureAwait(false);
                    }
                }
            }
        }
예제 #3
0
 public static ProfileOperation Profile([NotNull] ProfileSession session, [NotNull] ProfileOperationSpecification specification)
 => ProfilerFactory.GetCurrentProfiler().Profile(session, specification);
예제 #4
0
 public static ProfileSession StartProfiling([CanBeNull] IDictionary <string, object> additionalSessionData = null)
 => ProfilerFactory.GetCurrentProfiler().Start(additionalSessionData);
예제 #5
0
 public static IProfiler GetCurrentProfiler() => ProfilerFactory.GetCurrentProfiler();
예제 #6
0
 /// <summary>
 ///     Stops specified profile <paramref name="session"/> and stores the results.
 /// </summary>
 public static void StopProfiling([NotNull] ProfileSession session, [CanBeNull] IDictionary <string, object> additionalSessionData = null)
 => ProfilerFactory.GetCurrentProfiler().Stop(session, additionalSessionData);
예제 #7
0
 public ProfiledDbCommand(DbCommand innerCommand)
 {
     this.InnerCommand = innerCommand;
     this.profiler     = ProfilerFactory.GetCurrentProfiler();
 }