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; }
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; }
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 }); }
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 }); }
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)); }
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(); }
public void Dispose() { ThreadTimes fromCurrentThread = ThreadTimes.GetFromCurrentThread(); this.logger.Log(this.marker, "CpuTime", fromCurrentThread.Kernel - this.beginThreadTimes.Kernel + fromCurrentThread.User - this.beginThreadTimes.User); }