Beispiel #1
0
 private StringBuilder EmitSingleThread(TinyProfiler.ThreadContext threadContext)
 {
     List<TinyProfiler.TimedSection> sections = threadContext.Sections;
     int num = this.MaxParents(sections);
     int num2 = 20 + (15 * (num + 1));
     StringBuilder builder = new StringBuilder();
     builder.AppendLine($"<rect x="0.0" y="{this.YTopOfCurrentThread}" width="2000.0" height="{num2}" fill="url(#background)"  />");
     builder.AppendLine($"<text text-anchor="left" x="0" y="{this.YTopOfCurrentThread + 12}" font-size="12" font-family="Verdana" fill="rgb(0,0,0)"  >ThreadID: {threadContext.ThreadID} {threadContext.ThreadName}</text>");
     for (int i = 0; i != sections.Count; i++)
     {
         builder.Append(this.SectionRect(sections, i));
     }
     this.YTopOfCurrentThread += num2 + 50;
     return builder;
 }
        static void EmitSingleThread(TextWriter textWriter, TinyProfiler.ThreadContext threadContext, string processName)
        {
            var threadID = threadContext.ThreadID;

            textWriter.Write("{ \"pid\": \"");
            textWriter.Write(processName);
            textWriter.Write("\", \"tid\": ");
            textWriter.Write(threadID);
            textWriter.Write(", \"ph\":\"M\", \"name\": \"thread_name\", \"args\": {\"name\": \"");
            textWriter.Write(Escape(threadContext.ThreadName));
            textWriter.WriteLine("\"} },");

            var timedSections = threadContext.Sections;

            for (var i = 0; i != timedSections.Count; i++)
            {
                var section = timedSections[i];
                var startUS = section.StartInMicroSeconds;
                var durUS   = section.DurationInMicroSeconds;

                textWriter.Write("{ \"pid\": \"");
                textWriter.Write(processName);
                textWriter.Write("\", \"tid\": ");
                textWriter.Write(threadID);
                textWriter.Write(",\"ts\": ");
                textWriter.Write(startUS.ToString(CultureInfo.InvariantCulture));
                textWriter.Write(",\"dur\": ");
                textWriter.Write(durUS.ToString(CultureInfo.InvariantCulture));
                textWriter.Write(", \"ph\":\"X\", \"name\": \"");
                textWriter.Write(Escape(section.Label));
                textWriter.Write("\"");
                if (!string.IsNullOrEmpty(section.Details))
                {
                    textWriter.Write(", \"args\": { ");
                    //textWriter.Write("\", \"args\": { \"durationMS\": ");
                    //textWriter.Write(section.Duration.ToString(CultureInfo.InvariantCulture));
                    textWriter.Write("\"detail\": \"");
                    textWriter.Write(Escape(section.Details));
                    textWriter.WriteLine("\"}");
                }
                textWriter.WriteLine("},");
            }
        }