Ejemplo n.º 1
0
        public void Stop()
        {
            if (CurrentSession == this)
            {
                CurrentSession = null;
            }

            if (output == null)
            {
                return;
            }

            writer = new System.IO.StreamWriter(output);

            bool first = true;

            //convert to microseconds
            double scale = 1000000.0 / System.Diagnostics.Stopwatch.Frequency;

            BeginDocument();
            var stack = new List <int>();

            for (int i = 0, end = events.Count; i != end; ++i)
            {
                for (int j = stack.Count; j-- > 0;)
                {
                    var p = events[stack[j]];
                    if (p.parentIdx == i)
                    {
                        break;
                    }
                    EndEvent(p.name, p.end * scale);
                }
                var e = events[i];
                BeginEvent(e.name, e.start * scale, first);
                first = false;

                if (i + 1 < end && events[i + 1].parentIdx == i)
                {
                    stack.Add(i);
                }
                else
                {
                    EndEvent(e.name, e.end * scale);
                }
            }
            for (int j = stack.Count; j-- > 0;)
            {
                var p = events[stack[j]];
                EndEvent(p.name, p.end * scale);
            }
            EndDocument();

            writer.Flush();
            writer.Dispose();
            output.Close();
            output.Dispose();
            output = null;
        }
Ejemplo n.º 2
0
 public ProfileMarker(string name)
 {
     Session = ProfileSession.CurrentSession;
     if (Session != null)
     {
         Name = name;
         Session.Push(name);
     }
     else
     {
         Name = null;
     }
 }
Ejemplo n.º 3
0
 public ProfileMarker(string name, ProfileMarker parent)
 {
     Session = parent.Session;
     if (Session != null)
     {
         Name = name;
         Session.Push(name);
     }
     else
     {
         Name = null;
     }
 }
Ejemplo n.º 4
0
 public ProfileSession(System.IO.Stream o)
 {
     output         = o;
     CurrentSession = this;
 }