예제 #1
0
 public void Stop()
 {
     if (this.isRunning)
     {
         long timestamp = MyStopwatch.Timestamp;
         if (MyStopwatch.CpuTimeIsAvailable)
         {
             this.InternalGetElapsedCpuStatus();
         }
         long num = timestamp - this.startTimeStamp;
         this.elapsed  += num;
         this.isRunning = false;
         if (this.elapsed < 0L)
         {
             this.elapsed = 0L;
         }
         if (MyStopwatch.CpuTimeIsAvailable && this.elapsedCPU > 0L)
         {
             this.timerEndCPUID = (int)NativeMethods.GetCurrentProcessorNumber();
             if (this.timerEndCPUID != this.timerStartCPUID)
             {
                 this.cpuSwitchOccurred = true;
             }
             MyStopwatch.GetCurrentAndMaxMHz(this.timerEndCPUID, out this.timerEndCurrentMHz, out this.timerEndMaxMHz);
             if (this.timerStartCurrentMHz != this.timerEndCurrentMHz)
             {
                 this.cpuspeedChangeOccurred = true;
             }
         }
     }
 }
예제 #2
0
        public static MyStopwatch StartNew()
        {
            MyStopwatch myStopwatch = new MyStopwatch();

            myStopwatch.Start();
            return(myStopwatch);
        }
예제 #3
0
        private static int GetCurrentMHz(int cpuId)
        {
            int result;
            int num;

            MyStopwatch.GetCurrentAndMaxMHz(cpuId, out result, out num);
            return(result);
        }
예제 #4
0
 internal LatencyDetectionContext(LatencyDetectionLocation location, ContextOptions contextOptions, string version, object hash, params IPerformanceDataProvider[] providers)
 {
     this.latencyDetectionLocation = location;
     this.assemblyVersion          = version;
     this.StackTraceContext        = hash;
     this.contextOptions           = contextOptions;
     if ((contextOptions & ContextOptions.DoNotMeasureTime) == ContextOptions.DoNotMeasureTime)
     {
         this.timer = null;
     }
     else
     {
         this.timer = MyStopwatch.StartNew();
     }
     this.SetDataProviders(providers);
 }
예제 #5
0
 public void Start()
 {
     if (!this.isRunning)
     {
         this.startTimeStamp = MyStopwatch.Timestamp;
         if (MyStopwatch.CpuTimeIsAvailable)
         {
             using (SafeThreadHandle currentThread = NativeMethods.GetCurrentThread())
             {
                 this.timerStartThreadHandle = currentThread.DangerousGetHandle().ToInt64();
             }
             this.timerStartCPUID      = (int)NativeMethods.GetCurrentProcessorNumber();
             this.timerStartCurrentMHz = MyStopwatch.GetCurrentMHz(this.timerStartCPUID);
             this.timerEndCurrentMHz   = this.timerStartCurrentMHz;
             this.startCPUcycles       = MyStopwatch.CpuCycles;
         }
         this.isRunning = true;
     }
 }