Ejemplo n.º 1
0
 static Tracer()
 {
     _Root     = new MethodCallRecord(null, "root_frame");
     Current   = _Root;
     TotalTime = new Stopwatch();
     TotalTime.Reset();
     TotalTime.Start();
 }
Ejemplo n.º 2
0
        internal static void Pop_MethodCallrecord(long ElapsedTicks)
        {
            Debug.Assert(InstrumentationSwitch == true);

            Debug.Assert(!object.ReferenceEquals(Current, _Root), "root frame cannot be popped");
            Tracer.Current.m_TicksSpentInMethod += ElapsedTicks;
            Tracer.Current = Tracer.Current.ParrentCall;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// creates an report for this method;
        /// </summary>
        public MiniReport GetMiniReport(MethodCallRecord altRoot = null)
        {
            if (altRoot == null)
            {
                altRoot = this.Root;
            }

            return(new MiniReport()
            {
                M = this,
                RelativeRoot = altRoot
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds a new entry to <see cref="Calls"/> (if <paramref name="_name"/> does not exist), otherwise
        /// the existing entry is modified.
        /// </summary>
        public MethodCallRecord AddSubCall(string _name, long ElapsedTicks)
        {
            MethodCallRecord mcr;

            if (!this.Calls.TryGetValue(_name, out mcr))
            {
                mcr = new MethodCallRecord(this, _name);
                this.Calls.Add(_name, mcr);
            }
            mcr.CallCount++;
            mcr.m_TicksSpentInMethod += ElapsedTicks;

            return(mcr);
        }
Ejemplo n.º 5
0
        internal static MethodCallRecord LogDummyblock(long ticks, string _name)
        {
            Debug.Assert(InstrumentationSwitch == true);

            MethodCallRecord mcr;

            if (!Tracer.Current.Calls.TryGetValue(_name, out mcr))
            {
                mcr = new MethodCallRecord(Tracer.Current, _name);
                //mcr.IgnoreForExclusive = true;
                Tracer.Current.Calls.Add(_name, mcr);
            }
            mcr.CallCount++;
            //Debug.Assert(mcr.IgnoreForExclusive == true);
            mcr.m_TicksSpentInMethod += ticks;

            return(mcr);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Sets the time spend in respective method (see <see cref="TicksSpentInMethod"/>) and all child calls to zero.
        /// </summary>
        public void ResetRecursive(bool EliminateKilledTimeFromParrent = true)
        {
            if (EliminateKilledTimeFromParrent)
            {
                long toRemove = this.TicksSpentInMethod;

                for (MethodCallRecord p = this.ParrentCall; p != null; p = p.ParrentCall)
                {
                    p.m_TicksSpentInMethod -= toRemove;
                }
            }

            this.m_TicksSpentInMethod = 0;
            foreach (var c in Calls.Values)
            {
                c.ResetRecursive();
            }
        }
Ejemplo n.º 7
0
        internal static void Push_MethodCallRecord(string _name)
        {
            Debug.Assert(InstrumentationSwitch == true);

            //if (Tracer.Current != null) {
            MethodCallRecord mcr;

            if (!Tracer.Current.Calls.TryGetValue(_name, out mcr))
            {
                mcr = new MethodCallRecord(Tracer.Current, _name);
                Tracer.Current.Calls.Add(_name, mcr);
            }
            Tracer.Current = mcr;
            mcr.CallCount++;
            //} else {
            //    Debug.Assert(Tracer.Root == null);
            //    var mcr = new MethodCallRecord(Tracer.Current, _name);
            //    Tracer.Root = mcr;
            //    Tracer.Current = mcr;
            //}
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Sets the time spend in respective method (see <see cref="TicksSpentInMethod"/>) and in all child calls to zero. Can be configured to reset call count as well.
        /// </summary>
        public void ResetRecursive(bool EliminateKilledTimeFromParrent = true, bool EliminateCallcount = false)
        {
            if (EliminateKilledTimeFromParrent)
            {
                long toRemove = this.TicksExclusive;

                for (MethodCallRecord p = this.ParrentCall; p != null; p = p.ParrentCall)
                {
                    p.m_TicksSpentInMethod -= toRemove;
                }
            }
            this.m_TicksSpentInMethod -= this.TicksExclusive;

            foreach (var c in Calls.Values)
            {
                c.ResetRecursive(EliminateCallcount: EliminateCallcount);
            }
            if (EliminateCallcount)
            {
                this.CallCount = 0;
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// ctor.
 /// </summary>
 public MethodCallRecord(MethodCallRecord parrent, string n)
 {
     ParrentCall = parrent;
     this.Name   = n;
 }