--- a/Win32OperatingSystem.st Thu Aug 30 16:04:47 2007 +0200
+++ b/Win32OperatingSystem.st Thu Aug 30 16:21:48 2007 +0200
@@ -1299,6 +1299,7 @@
!Win32OperatingSystem class methodsFor:'accessing'!
performanceData
+ ^ PerformanceData
! !
!Win32OperatingSystem class methodsFor:'error messages'!
@@ -10282,119 +10283,6 @@
"Modified: 28.12.1995 / 14:13:41 / stefan"
! !
-!Win32OperatingSystem::PerformanceData class methodsFor:'# obsolete'!
-
-interruptsPerSecond
- |rawData1 rawData2 p1 p2 counterIdx counter1 counter2 irqs deltaTInNs deltaTInS irqsPerSecond|
-
- rawData1 := (Win32OperatingSystem registryEntry key:'HKEY_PERFORMANCE_DATA') valueNamed:'238'.
- Delay waitForSeconds:0.1.
- rawData2 := (Win32OperatingSystem registryEntry key:'HKEY_PERFORMANCE_DATA') valueNamed:'238'.
- p1 := self new fromRawBytes:rawData1.
- p2 := self new fromRawBytes:rawData2.
-
- counterIdx := (p1 dataArray first at:#Counters) findFirst:[:counter | (counter at:#CounterNameTitleIndex) = 148 "INTERRUPTS_INDEX" ].
- counter1 := (p1 dataArray first at:#Counters) at:counterIdx.
- counter2 := (p2 dataArray first at:#Counters) at:counterIdx.
-
- irqs := (counter2 at:#CounterValue) - (counter1 at:#CounterValue).
- deltaTInNs := (p2 perfTime100nSec - p1 perfTime100nSec) * 100.
- deltaTInS := deltaTInNs / 1000 / 1000 / 1000.
- irqsPerSecond := (irqs / deltaTInS) asFloat.
- ^ irqsPerSecond
-
- "
- self interruptsPerSecond
- "
-!
-
-processorTimeFraction
- |rawData1 rawData2 p1 p2 counterIdx counter1 counter2 d deltaTIn100Ns deltaTInUs deltaTInS dPerSecond load1024|
-
- rawData1 := (Win32OperatingSystem registryEntry key:'HKEY_PERFORMANCE_DATA') valueNamed:'238'.
- Delay waitForSeconds:0.1.
- rawData2 := (Win32OperatingSystem registryEntry key:'HKEY_PERFORMANCE_DATA') valueNamed:'238'.
- p1 := self new fromRawBytes:rawData1.
- p2 := self new fromRawBytes:rawData2.
-
- deltaTIn100Ns := (p2 perfTime100nSec - p1 perfTime100nSec).
- deltaTInUs := deltaTIn100Ns / 10.
- deltaTInS := deltaTInUs / 1000 / 1000.
-
- counterIdx := (p1 objectArray first at:#Counters) findFirst:[:counter | (counter at:#CounterNameTitleIndex) = 6 "CPU_USAGE_INDEX" ].
- counter1 := (p1 objectArray first at:#Counters) at:counterIdx.
- counter2 := (p2 objectArray first at:#Counters) at:counterIdx.
-
- d := (counter2 at:#CounterValueArray) first - (counter1 at:#CounterValueArray) first.
- d := d bitShift:10.
- dPerSecond := (d / deltaTIn100Ns) asFloat.
- load1024 := 1024 - dPerSecond.
-
- ^ load1024 / 1024 * 100
-
- "
- self processorTimeFraction
- "
-!
-
-processorTimeFraction2
- |rawData1 rawData2 p1 p2 counterIdx counter1 counter2 d deltaTIn100Ns deltaTInUs deltaTInS dPerSecond load1024|
-
- rawData1 := (Win32OperatingSystem registryEntry key:'HKEY_PERFORMANCE_DATA') valueNamed:'238'.
- Delay waitForSeconds:0.1.
- rawData2 := (Win32OperatingSystem registryEntry key:'HKEY_PERFORMANCE_DATA') valueNamed:'238'.
- p1 := self new fromRawBytes:rawData1.
- p2 := self new fromRawBytes:rawData2.
-
- deltaTIn100Ns := (p2 perfTime100nSec - p1 perfTime100nSec).
- deltaTInUs := deltaTIn100Ns / 10.
- deltaTInS := deltaTInUs / 1000 / 1000.
-
- counterIdx := (p1 objectArray first at:#Counters) findFirst:[:counter | (counter at:#CounterNameTitleIndex) = 6 "CPU_USAGE_INDEX" ].
- counter1 := (p1 objectArray first at:#Counters) at:counterIdx.
- counter2 := (p2 objectArray first at:#Counters) at:counterIdx.
-
- d := (counter2 at:#CounterValueArray) second - (counter1 at:#CounterValueArray) second.
- d := d bitShift:10.
- dPerSecond := (d / deltaTIn100Ns) asFloat.
- load1024 := 1024 - dPerSecond.
-
- ^ load1024 / 1024 * 100
-
- "
- self processorTimeFraction2
- "
-!
-
-processorTimeFraction3
- |rawData1 rawData2 p1 p2 counterIdx counter1 counter2 d deltaTIn100Ns deltaTInUs deltaTInS dPerSecond load1024|
-
- rawData1 := (Win32OperatingSystem registryEntry key:'HKEY_PERFORMANCE_DATA') valueNamed:'238'.
- Delay waitForSeconds:0.1.
- rawData2 := (Win32OperatingSystem registryEntry key:'HKEY_PERFORMANCE_DATA') valueNamed:'238'.
- p1 := self new fromRawBytes:rawData1.
- p2 := self new fromRawBytes:rawData2.
-
- deltaTIn100Ns := (p2 perfTime100nSec - p1 perfTime100nSec).
- deltaTInUs := deltaTIn100Ns / 10.
- deltaTInS := deltaTInUs / 1000 / 1000.
-
- counterIdx := (p1 objectArray first at:#Counters) findFirst:[:counter | (counter at:#CounterNameTitleIndex) = 6 "CPU_USAGE_INDEX" ].
- counter1 := (p1 objectArray first at:#Counters) at:counterIdx.
- counter2 := (p2 objectArray first at:#Counters) at:counterIdx.
-
- d := (counter2 at:#CounterValueArray) third - (counter1 at:#CounterValueArray) third.
- d := d bitShift:10.
- dPerSecond := (d / deltaTIn100Ns) asFloat.
- load1024 := 1024 - dPerSecond.
-
- ^ load1024 / 1024 * 100
-
- "
- self processorTimeFraction3
- "
-! !
-
!Win32OperatingSystem::PerformanceData class methodsFor:'accessing'!
counterIndexTextDictionary
@@ -10864,6 +10752,86 @@
^ 'Global'
! !
+!Win32OperatingSystem::PerformanceData::Processor class methodsFor:'puplic'!
+
+interruptsPerSecond
+
+ "
+ self interruptsPerSecond
+ "
+
+ |p1 p2 index counter1 counter2 resultArray deltaTInNs deltaTInS cValueArray1 cValueArray2|
+
+ "alive time must be smaller than the used diff time, otherwise we cant calc sth"
+ self assert:(self aliveTime < 100).
+
+ p1 := self data.
+ Delay waitForMilliseconds:100.
+ p2 := self data.
+
+ index := (p1 objectArray first at:#Counters) findFirst:[:aCounter|(aCounter at:#CounterNameTitleIndex) = 148 "INTERRUPTS_INDEX"].
+ counter1 := (p1 objectArray first at:#Counters) at:index.
+ counter2 := (p2 objectArray first at:#Counters) at:index.
+
+ resultArray := OrderedCollection new.
+ deltaTInNs := (p2 perfTime100nSec - p1 perfTime100nSec) * 100.
+ deltaTInS := deltaTInNs / 1000 / 1000 / 1000.
+
+ cValueArray1 := counter1 at:#CounterValueArray.
+ cValueArray2 := counter2 at:#CounterValueArray.
+
+ 1 to:cValueArray1 size do:[:idx|
+ |irqs irqsPerSecond|
+
+ irqs := (cValueArray2 at:idx) - (cValueArray1 at:idx).
+ irqsPerSecond := (irqs / deltaTInS) asFloat.
+
+ resultArray add:irqsPerSecond.
+ ].
+
+ ^ resultArray
+!
+
+processorTimeFraction
+
+ "
+ self processorTimeFraction
+ "
+
+ |p1 p2 index counter1 counter2 resultArray deltaTIn100Ns cValueArray1 cValueArray2|
+
+ "alive time must be smaller than the used diff time, otherwise we cant calc sth"
+ self assert:(self aliveTime < 100).
+
+ p1 := self data.
+ Delay waitForMilliseconds:100.
+ p2 := self data.
+
+ index := (p1 objectArray first at:#Counters) findFirst:[:aCounter|(aCounter at:#CounterNameTitleIndex) = 6].
+ counter1 := (p1 objectArray first at:#Counters) at:index.
+ counter2 := (p2 objectArray first at:#Counters) at:index.
+
+ resultArray := OrderedCollection new.
+ deltaTIn100Ns := (p2 perfTime100nSec - p1 perfTime100nSec).
+
+ cValueArray1 := counter1 at:#CounterValueArray.
+ cValueArray2 := counter2 at:#CounterValueArray.
+
+ 1 to:cValueArray1 size do:[:idx|
+ |diff dPerSecond load1024|
+
+ diff := (cValueArray2 at:idx) - (cValueArray1 at:idx).
+ diff := diff bitShift:10.
+
+ dPerSecond := (diff / deltaTIn100Ns) asFloat.
+ load1024 := 1024 - dPerSecond.
+
+ resultArray add:(load1024 / 1024 * 100).
+ ].
+
+ ^ resultArray
+! !
+
!Win32OperatingSystem::PerformanceData::Processor class methodsFor:'queries'!
aliveTime
@@ -13703,7 +13671,7 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.290 2007-08-30 14:04:47 sr Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.291 2007-08-30 14:21:48 sr Exp $'
! !
Win32OperatingSystem initialize!