示例#1
0
        public void PushAsyncActivity(string activity)
        {
            Stack <PerformanceCounterWrapper> item = Trace.Metadata[PerformanceCounterWrapper.LocalStorageKey] as Stack <PerformanceCounterWrapper>;
            PerformanceCounterWrapper         performanceCounterWrapper = this[activity];

            item.Push(performanceCounterWrapper);
            performanceCounterWrapper.ResetClock();
        }
示例#2
0
        public void StopClock()
        {
            if (this.clockEnd != DateTime.MinValue)
            {
                return;
            }
            this.clockEnd = DateTime.UtcNow;
            PerformanceCounterWrapper ticks = this;

            ticks.totalTicks = ticks.totalTicks + (this.clockEnd.Ticks - this.clockStart.Ticks);
        }
示例#3
0
        public override string ToString()
        {
            if (this.clockEnd == DateTime.MinValue)
            {
                this.StopClock();
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat("name={0} total time={1}ms ", this.title, PerformanceCounterWrapper.ConvertTicksToMilliseconds(this.totalTicks));
            foreach (KeyValuePair <string, string> metadatum in this.metadata)
            {
                stringBuilder.AppendFormat("{0}={1} ", metadatum.Key, metadatum.Value);
            }
            foreach (KeyValuePair <string, long> @event in this.events)
            {
                stringBuilder.AppendFormat("{0}={1}ms({2}%) ", @event.Key, PerformanceCounterWrapper.ConvertTicksToMilliseconds(@event.Value), (this.totalTicks == (long)0 ? (long)0 : @event.Value * (long)100 / this.totalTicks));
            }
            foreach (KeyValuePair <string, PerformanceCounterWrapper> counter in this.counters)
            {
                stringBuilder.AppendFormat("[ {0} ] ", counter.Value.ToString());
            }
            return(stringBuilder.ToString());
        }