public ProfiledSection(IProfilerSink profilerSink, TimeStatistics timeStatistics) { this.profilerSink = profilerSink; this.timeStatistics = timeStatistics; TracingAnalyzer.ClearStatsForCurrentThread(); stopwatch = Stopwatch.StartNew(); }
public void Dispose() { stopwatch.Stop(); if (timeStatistics.RegisterDuration(stopwatch.ElapsedMilliseconds)) { var stats = TracingAnalyzer.GetStatsForCurrentThread(); var trace = TracingAnalyzerStatsFormatter.Format(stats, stopwatch.ElapsedMilliseconds); profilerSink.WhenCurrentDurationIsLongerThanPercentile99(stopwatch.Elapsed, timeStatistics, trace); } }