Exemplo n.º 1
0
 public static RequestStatisticsForThread Begin()
 {
     return(new RequestStatisticsForThread
     {
         begin = ThreadTimes.GetFromCurrentThread()
     });
 }
 public void Start()
 {
     this.EnforceInternalState(ContactsUploaderPerformanceTracker.InternalState.Stopped, "Start");
     this.elapsedTimeBookmarks = new List <ContactsUploaderPerformanceTracker.ElapsedTimeBookmark>();
     this.stopwatch.Start();
     this.startThreadTimes          = ThreadTimes.GetFromCurrentThread();
     this.startStorePerformanceData = RpcDataProvider.Instance.TakeSnapshot(true);
     this.internalState             = ContactsUploaderPerformanceTracker.InternalState.Started;
 }
Exemplo n.º 3
0
        private void ThreadTimesReadCallback(ThreadTimes arg)
        {
            //Temporary solution until situation with missing thread create record is cleared
            if (GetThreadByInternalId(arg.InternalId) == null)
            {
                AddThread(new Thread {
                    InternalId = arg.InternalId
                }, arg.TicksFromStart);
            }

            Threads.GetByInternalId(arg.InternalId).CpuUtilizationHistory.RecordCpuUsage(arg.TicksFromStart, arg.UserTime);
        }
Exemplo n.º 4
0
 public virtual void Start()
 {
     this.EnforceInternalState(PerformanceTrackerBase.InternalState.Stopped, "Start");
     this.stopwatch.Start();
     this.startThreadTimes              = ThreadTimes.GetFromCurrentThread();
     this.startStorePerformanceData     = RpcDataProvider.Instance.TakeSnapshot(true);
     this.startDirectoryPerformanceData = PerformanceContext.Current.TakeSnapshot(true);
     if (this.mailboxSession != null)
     {
         this.startCumulativeRPCPerformanceStatistics = this.mailboxSession.GetStoreCumulativeRPCStats();
     }
     this.internalState = PerformanceTrackerBase.InternalState.Started;
 }
 public CpuPerformanceTracker(string marker, IPerformanceDataLogger logger)
 {
     if (string.IsNullOrEmpty(marker))
     {
         throw new ArgumentNullException("marker");
     }
     if (logger == null)
     {
         throw new ArgumentNullException("logger");
     }
     this.marker           = marker;
     this.logger           = logger;
     this.beginThreadTimes = ThreadTimes.GetFromCurrentThread();
 }
        public void Stop()
        {
            this.EnforceInternalState(ContactsUploaderPerformanceTracker.InternalState.Started, "Stop");
            this.stopwatch.Stop();
            ThreadTimes     fromCurrentThread = ThreadTimes.GetFromCurrentThread();
            PerformanceData pd = RpcDataProvider.Instance.TakeSnapshot(false);

            this.internalState = ContactsUploaderPerformanceTracker.InternalState.Stopped;
            this.cpuTime      += fromCurrentThread.Kernel - this.startThreadTimes.Kernel + (fromCurrentThread.User - this.startThreadTimes.User);
            PerformanceData performanceData = pd - this.startStorePerformanceData;

            this.storeRpcLatency += performanceData.Latency;
            this.storeRpcCount   += (int)performanceData.Count;
        }
Exemplo n.º 7
0
 private OperationTracker(string context, ILogger logger)
 {
     ThreadTimes.GetFromCurrentThread(out this.startingKernelTime, out this.startingUserTime);
     this.context     = context;
     this.logger      = logger;
     this.timeTracker = Stopwatch.StartNew();
     this.logger.Log(MigrationEventType.Instrumentation, "BEGIN: [TID:{0}] [{1} ms] [{2} ms Kernel] [{3} ms User] - {4}", new object[]
     {
         Thread.CurrentThread.ManagedThreadId,
         this.timeTracker.ElapsedMilliseconds,
         this.startingKernelTime.TotalMilliseconds,
         this.startingUserTime.TotalMilliseconds,
         this.context
     });
 }
Exemplo n.º 8
0
        protected override void InternalDispose(bool disposing)
        {
            this.timeTracker.Stop();
            TimeSpan t;
            TimeSpan t2;

            ThreadTimes.GetFromCurrentThread(out t, out t2);
            this.logger.Log(MigrationEventType.Instrumentation, "END: [TID:{0}] [{1} ms] [{2} ms Kernel] [{3} ms User] - {4}", new object[]
            {
                Thread.CurrentThread.ManagedThreadId,
                this.timeTracker.ElapsedMilliseconds,
                (t - this.startingKernelTime).TotalMilliseconds,
                (t2 - this.startingUserTime).TotalMilliseconds,
                this.context
            });
        }
Exemplo n.º 9
0
        public RequestStatistics End(RequestStatisticsType tag, string destination)
        {
            ThreadTimes fromCurrentThread = ThreadTimes.GetFromCurrentThread();

            if (this.begin == null || fromCurrentThread == null)
            {
                return(null);
            }
            long timeTaken = (long)(fromCurrentThread.Kernel.TotalMilliseconds - this.begin.Kernel.TotalMilliseconds) + (long)(fromCurrentThread.User.TotalMilliseconds - this.begin.User.TotalMilliseconds);

            if (destination == null)
            {
                return(RequestStatistics.Create(tag, timeTaken));
            }
            return(RequestStatistics.Create(tag, timeTaken, destination));
        }
Exemplo n.º 10
0
        public virtual void Stop()
        {
            this.EnforceInternalState(PerformanceTrackerBase.InternalState.Started, "Stop");
            this.stopwatch.Stop();
            ThreadTimes     fromCurrentThread = ThreadTimes.GetFromCurrentThread();
            PerformanceData pd  = RpcDataProvider.Instance.TakeSnapshot(false);
            PerformanceData pd2 = PerformanceContext.Current.TakeSnapshot(false);

            this.internalState = PerformanceTrackerBase.InternalState.Stopped;
            this.CpuTime      += fromCurrentThread.Kernel - this.startThreadTimes.Kernel + (fromCurrentThread.User - this.startThreadTimes.User);
            PerformanceData performanceData = pd - this.startStorePerformanceData;

            this.StoreRpcLatency += performanceData.Latency;
            this.StoreRpcCount   += (int)performanceData.Count;
            PerformanceData performanceData2 = pd2 - this.startDirectoryPerformanceData;

            this.DirectoryLatency += performanceData2.Latency;
            this.DirectoryCount   += (int)performanceData2.Count;
            this.CalculateStorePerformanceStatistics();
        }
Exemplo n.º 11
0
        public void Dispose()
        {
            ThreadTimes fromCurrentThread = ThreadTimes.GetFromCurrentThread();

            this.logger.Log(this.marker, "CpuTime", fromCurrentThread.Kernel - this.beginThreadTimes.Kernel + fromCurrentThread.User - this.beginThreadTimes.User);
        }