コード例 #1
0
        public void ServerTimingFormat()
        {
            var mp = new MiniProfiler("Test", Options);

            using (mp.Step("Main"))
            {
                using (mp.Step("Sub Step 1"))
                {
                    mp.Head.AddCustomTiming("A", new CustomTiming()
                    {
                        DurationMilliseconds = 5
                    });
                }
                using (mp.Step("Sub Step 2"))
                {
                    mp.Head.AddCustomTiming("A", new CustomTiming()
                    {
                        DurationMilliseconds = 10.1m
                    });
                    mp.Head.AddCustomTiming("B", new CustomTiming()
                    {
                        DurationMilliseconds = 8.2345m
                    });
                }
            }
            mp.Stop();
            mp.DurationMilliseconds = 5m + 10.1m + 8.2345m; // Since we're synthetic here, need to set it
            var st = mp.GetServerTimingHeader();

            Assert.Equal(@"A;desc=""A"";dur=15.1,B;desc=""B"";dur=8.23,total;desc=""Total"";dur=23.33", st);
        }