示例#1
0
        public IEnumerable <WeatherForecast> Get()
        {
            var scoped = MiniProfiler.Current;

            scoped.Inline(() => Slowpoke.Sleep(3, 4, 20), "slow with MiniProvider.Current");
            try
            {
                using (profilerContainer.Step("forecasting"))
                {
                    Thread.Sleep(15);
                    var rng = new Random();
                    using (profilerContainer.Step("returning"))
                    {
                        Thread.Sleep(70);

                        return(Enumerable.Range(1, 5).Select(index => CreateForecast(index, rng))
                               .ToArray());
                    }
                }
            }
            finally
            {
                scoped.AddProfilerResults(profilerContainer.GetProfiler());
            }
        }
示例#2
0
 public MiniProfiler calInside(int idx)
 {
     profiler.Inline(() => Slowpoke.Sleep(2, 5, 20), "inside inline");
     using (profiler.Step("inside step"))
         Slowpoke.Sleep(2, 4, 10);
     // mp.Stop();
     return(profiler);
 }
 void DoWork(object state)
 {
     while (!token.IsCancellationRequested)
     {
         var profiler = MiniProfiler.StartNew($"work {callCount++}");
         Slowpoke.Sleep(1, 5, 20);
         using (profiler.Step("one"))
             Slowpoke.Sleep(1, 5, 10);
         Slowpoke.Sleep(2, 4, 5);
         using (profiler.StepIf("may be", 100))
             Slowpoke.Sleep(2, 6, 30);
         using (profiler.Step("last"))
             Slowpoke.Sleep(1, 5, 10);
         var inner = new UnitOfWork(factory().GetProfiler()).calInside(callCount);
         profiler.AddProfilerResults(inner);
         profiler.Stop();
         Thread.Sleep(5 * 1000);
     }
 }