コード例 #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();
 }