Ejemplo n.º 1
0
 /// <summary>
 /// Renders a full HTML page for the share link in MiniProfiler.
 /// </summary>
 /// <param name="profiler">The profiler to render a tag for.</param>
 /// <param name="path">The root path that MiniProfiler is being served from.</param>
 /// <returns>A full HTML page for this MiniProfiler.</returns>
 public static string SingleResultHtml(MiniProfiler profiler, string path)
 {
     var sb = StringBuilderCache.Get();
     sb.Append("<html><head><title>");
     sb.Append(profiler.Name);
     sb.Append(" (");
     sb.Append(profiler.DurationMilliseconds.ToString(CultureInfo.InvariantCulture));
     sb.Append(" ms) - Profiling Results</title><script>var profiler = ");
     sb.Append(profiler.ToJson(htmlEscape: true));
     sb.Append(";</script>");
     sb.Append(Includes(profiler, path: path, isAuthorized: true));
     sb.Append(@"</head><body><div class=""mp-result-full""></div></body></html>");
     return sb.ToString();
 }
Ejemplo n.º 2
0
 private static string ResultsFullPage(HttpContext context, MiniProfiler profiler)
 {
     context.Response.ContentType = "text/html";
     return(new StringBuilder()
            .AppendLine("<html><head>")
            .AppendFormat("<title>{0} ({1} ms) - MvcMiniProfiler Results</title>", profiler.Name, profiler.DurationMilliseconds)
            .AppendLine()
            .AppendLine("<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'></script>")
            .Append("<script type='text/javascript'> var profiler = ")
            .Append(MiniProfiler.ToJson(profiler))
            .AppendLine(";</script>")
            .Append(RenderIncludes(profiler)) // figure out how to better pass display options
            .AppendLine("</head><body><div class='profiler-result-full'></div></body></html>")
            .ToString());
 }
Ejemplo n.º 3
0
        /// <summary>
        /// results full page.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="profiler">The profiler.</param>
        /// <returns>a string containing the results page</returns>
        private static string ResultsFullPage(HttpContext context, MiniProfiler profiler)
        {
            context.Response.ContentType = "text/html";

            var template = GetResource("share.html");

            return(template.Format(new
            {
                name = profiler.Name,
                duration = profiler.DurationMilliseconds.ToString(CultureInfo.InvariantCulture),
                path = VirtualPathUtility.ToAbsolute(MiniProfiler.Settings.RouteBasePath).EnsureTrailingSlash(),
                json = MiniProfiler.ToJson(profiler),
                includes = RenderIncludes(profiler),
                version = MiniProfiler.Settings.Version
            }));
        }
Ejemplo n.º 4
0
        public void ParentMapping()
        {
            var mp = new MiniProfiler("Test", Options);

            using (mp.Step("Main"))
            {
                using (mp.Step("Sub Step 1"))
                {
                    using (mp.CustomTiming("cat", "Command 1")) {}
                    using (mp.CustomTiming("cat", "Command 2")) {}
                    using (mp.CustomTiming("cat", "Command 3")) {}
                }
                using (mp.Step("Sub Step 2"))
                {
                    using (mp.CustomTiming("cat", "Command 4")) {}
                    using (mp.CustomTiming("cat", "Command 5")) {}
                    using (mp.CustomTiming("cat", "Command 6")) {}
                }
            }
            mp.Stop();
            var json = mp.ToJson();

            var deserialized = MiniProfiler.FromJson(json);
            var root         = deserialized.Root;

            foreach (var t in root.Children)
            {
                Assert.Equal(root, t.ParentTiming);
                Assert.True(root == t.ParentTiming);

                foreach (var tc in t.Children)
                {
                    Assert.Equal(t, tc.ParentTiming);
                    Assert.True(t == tc.ParentTiming);
                }
            }
        }
        private static string CompareResultPage(HttpContext context, List <ReportAnalyser.SavedTimingsData> savedTimingsData)
        {
            context.Response.ContentType = "text/html";

            var template = GetResource("ComparisonReport.htm");

            return(template.Format(new
            {
                name = "Report Comparison",
                duration = 0,
                path = VirtualPathUtility.ToAbsolute(MiniProfiler.Settings.RouteBasePath).EnsureTrailingSlash(),
                json = MiniProfiler.ToJson(savedTimingsData),
                includes = RenderIncludes(savedTimingsData),
                version = MiniProfiler.Settings.Version
            }));

            //StringBuilder htmlOutput= new StringBuilder();
            //if (savedTimingsData != null)
            //{
            //    foreach (ReportAnalyser.SavedTimingsData timings in savedTimingsData)
            //        htmlOutput.Append(Parse(context, timings));
            //}
            //return htmlOutput.ToString();
        }
Ejemplo n.º 6
0
 private static string ResultsJson(IResponse httpRes, MiniProfiler profiler)
 {
     httpRes.ContentType = "application/json";
     return(MiniProfiler.ToJson(profiler));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// set the JSON results and the content type.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="profiler">The profiler.</param>
 /// <returns>a string containing the JSON results.</returns>
 private static string ResultsJson(HttpContext context, MiniProfiler profiler)
 {
     context.Response.ContentType = "application/json";
     return(MiniProfiler.ToJson(profiler));
 }
 public string ComplexSerialize() => _complexProfiler.ToJson();
 public string SimpleSerialize() => _simpleProfiler.ToJson();
Ejemplo n.º 10
0
 private void Log(MiniProfiler profiler)
 {
     if (_logger.IsEnabled(LogLevel.Information))
     {
         _logger.LogInformation("Profiling Information: {@ProfileInfo}", JsonConvert.DeserializeObject <object>(profiler.ToJson()));
     }
 }
Ejemplo n.º 11
0
 private ILogger GetLogWithContext(ILogger logger)
 {
     return(logger
            .ForContext("MiniProfiler", JsonConvert.DeserializeObject <dynamic>(MiniProfiler.ToJson()), true));
 }