CPUUsage Multi-processeur
Merci pour ta patience Tmyke,
Si malgré, le fait que les résultats soient supérieures à 100 et qu'il varient tout de même, cela pourrais provenir d'un problème d'échelle lors de la conversion. Pourrais tu donc, avec le dernier code refaire le test et remplacer le 10000 ligne 94 (env.) par 100000
If DiffTime > 0 : CpuTime = (((CpuTime) / (DiffTime)) / NumberOfProcessors) * 100000 : EndIf
Si par contre le taux d'uilisation par coeur ne varie pas, c'est une autre problème à étudier.
Encore Merci
Si malgré, le fait que les résultats soient supérieures à 100 et qu'il varient tout de même, cela pourrais provenir d'un problème d'échelle lors de la conversion. Pourrais tu donc, avec le dernier code refaire le test et remplacer le 10000 ligne 94 (env.) par 100000
If DiffTime > 0 : CpuTime = (((CpuTime) / (DiffTime)) / NumberOfProcessors) * 100000 : EndIf
Si par contre le taux d'uilisation par coeur ne varie pas, c'est une autre problème à étudier.
Encore Merci
-
- Messages : 1554
- Inscription : lun. 24/juil./2006 6:44
- Localisation : vosges (France) 47°54'39.06"N 6°20'06.39"E
Bon, j'ai essayé plusieurs valeurs, 20000 semble la plus appropriée, mais le soucis
c'est que je monte au dessus de 100 souvent.
Avec 100000 comme tu le suggerais, j'ai toujours 0 et sur les 4 coeurs.
Autre PB, le total est de 50% quand je lance une appli, alors qui est bien de 25% dans
le gestionnaire de tâches...
Meme si je ne connais pas ce genre de code, je vais voir si je peux trouver la faille...
c'est que je monte au dessus de 100 souvent.
Avec 100000 comme tu le suggerais, j'ai toujours 0 et sur les 4 coeurs.
Autre PB, le total est de 50% quand je lance une appli, alors qui est bien de 25% dans
le gestionnaire de tâches...
Meme si je ne connais pas ce genre de code, je vais voir si je peux trouver la faille...
Force et sagesse...
Je viens de faire des modifs, (sans doute y a t'il un problèmes avec le fait que le pourcentage renvoyé est à 25% et après recalcul est converti à 100%), je viens de regarder sur un vieux pc (733MHz), ça marche,
Donc voila le code modifié (avec ajout du temps au format H:M:S:MS)
Et encore merci pour tous tes tests
Donc voila le code modifié (avec ajout du temps au format H:M:S:MS)
Et encore merci pour tous tes tests
Structure SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
IdleTime.q
KernelTime.q
UserTime.q
Reserved1.q[3]
EndStructure
#SystemProcessorPerformanceInformation = 8
#SysProcPerfInfoLength = 48
#PROCESS_QUERY_INFORMATION = $400
#HUNDRED_NANOSEC = 10000000
Declare.l cpu_count()
Global Frequency.q, TimeStart.q
Global NumberOfProcessors = cpu_count()
Global Dim CpuInfo.SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION(NumberOfProcessors)
Global Dim KernelTimesStart.d(NumberOfProcessors+1)
Global Dim UserTimesStart.d(NumberOfProcessors+1)
Global Dim IdleTimesStart.d(NumberOfProcessors+1)
Global Dim KernelTimesStop.d(NumberOfProcessors+1)
Global Dim UserTimesStop.d(NumberOfProcessors+1)
Global Dim IdleTimesStop.d(NumberOfProcessors+1)
Global Dim KernelTimesDelta.d(NumberOfProcessors+1)
Global Dim UserTimesDelta.d(NumberOfProcessors+1)
Global Dim IdleTimesDelta.d(NumberOfProcessors+1)
Global Dim CpuUsages.d(NumberOfProcessors+1)
Procedure.l cpu_count() ; Retourne le nombre de processeur
Protected SI.SYSTEM_INFO
GetSystemInfo_ (@SI)
ProcedureReturn SI\dwNumberOfProcessors
EndProcedure
Procedure.s TimeConvert(time.q)
hr.l = Round (time/36000000000, 0)
time = time-(hr*36000000000)
min.l = Round (time/600000000, 0)
time = time-(min*600000000)
sec.l = Round (time/10000000, 0)
time = time-(sec*10000000)
ms.l = Round (time/10000, 0)
ProcedureReturn Str (hr)+ ":" + RSet ( Str (min), 2, "0" )+ ":" + RSet ( Str (sec), 2, "0" )+ ":" + RSet ( Str (ms), 3, "0" )
EndProcedure
Procedure GetProcessorsTimes(start = #True )
Protected Lib
Lib = OpenLibrary ( #PB_Any , "ntdll.dll" )
If Lib
If CallFunction (Lib, "NtQuerySystemInformation" , #SystemProcessorPerformanceInformation , @CpuInfo(), #SysProcPerfInfoLength * NumberOfProcessors, 0) = 0
If start = #True
KernelTimesStart(NumberOfProcessors) = 0
IdleTimesStart(NumberOfProcessors) = 0
UserTimesStart(NumberOfProcessors) = 0
For i = 0 To NumberOfProcessors - 1
KernelTimesStart(i) = CpuInfo(i)\KernelTime
IdleTimesStart(i) = CpuInfo(i)\IdleTime
UserTimesStart(i) = CpuInfo(i)\UserTime
KernelTimesStart(NumberOfProcessors) = KernelTimesStart(NumberOfProcessors) + CpuInfo(i)\KernelTime
IdleTimesStart(NumberOfProcessors) = IdleTimesStart(NumberOfProcessors) + CpuInfo(i)\IdleTime
UserTimesStart(NumberOfProcessors) = UserTimesStart(NumberOfProcessors) + CpuInfo(i)\UserTime
Next
Else
KernelTimesStop(NumberOfProcessors) = 0
IdleTimesStop(NumberOfProcessors) = 0
UserTimesStop(NumberOfProcessors) = 0
For i = 0 To NumberOfProcessors - 1
KernelTimesStop(i) = CpuInfo(i)\KernelTime
IdleTimesStop(i) = CpuInfo(i)\IdleTime
UserTimesStop(i) = CpuInfo(i)\UserTime
KernelTimesStop(NumberOfProcessors) = KernelTimesStop(NumberOfProcessors) + CpuInfo(i)\KernelTime
IdleTimesStop(NumberOfProcessors) = IdleTimesStop(NumberOfProcessors) + CpuInfo(i)\IdleTime
UserTimesStop(NumberOfProcessors) = UserTimesStop(NumberOfProcessors) + CpuInfo(i)\UserTime
Next
EndIf
EndIf
CloseLibrary (Lib)
EndIf
EndProcedure
Procedure refresh()
Protected CpuTime.d, CurTime.q, DiffTime.d
QueryPerformanceCounter_ (@CurTime)
GetProcessorsTimes( #False )
CpuUsages(NumberOfProcessors) = 0
For i = 0 To NumberOfProcessors - 1
KernelTimesDelta(i) = KernelTimesStop(i) - KernelTimesStart(i)
UserTimesDelta(i) = UserTimesStop(i) - UserTimesStart(i)
IdleTimesDelta(i) = IdleTimesStop(i) - IdleTimesStart(i)
CpuTime = (KernelTimesDelta(i) + UserTimesDelta(i) + IdleTimesDelta(i))
DiffTime = (CurTime - TimeStart) / Frequency
If DiffTime > 0 : CpuTime = ((CpuTime) / (DiffTime)) / NumberOfProcessors : EndIf
CpuUsages(i) = (100 * (1 - CpuTime / #HUNDRED_NANOSEC ))
If NumberOfProcessors = 1 : CpuUsages(i) = 100 + CpuUsages(i) : EndIf
If CpuUsages(i) < 0 : CpuUsages(i) = 0 : EndIf
If CpuUsages(i) > 100 : CpuUsages(i) = 100 : EndIf
Debug Str (i)+ " : " + StrD (CpuUsages(i), 3)
CpuUsages(NumberOfProcessors) = CpuUsages(NumberOfProcessors) + CpuUsages(i)
CpuUsages(i) = CpuUsages(i) * NumberOfProcessors
KernelTimesStart(i) = KernelTimesStop(i)
UserTimesStart(i) = UserTimesStop(i)
IdleTimesStart(i) = IdleTimesStop(i)
SetGadgetItemText (1, i, StrD (CpuUsages(i), 3), 1)
SetGadgetItemText (1, i, TimeConvert(KernelTimesStart(i)), 2)
SetGadgetItemText (1, i, TimeConvert(UserTimesStart(i)), 3)
SetGadgetItemText (1, i, TimeConvert(IdleTimesStart(i)), 4)
Next
KernelTimesStart(NumberOfProcessors) = KernelTimesStop(NumberOfProcessors)
UserTimesStart(NumberOfProcessors) = UserTimesStop(NumberOfProcessors)
IdleTimesStart(NumberOfProcessors) = IdleTimesStop(NumberOfProcessors)
SetGadgetItemText (1, NumberOfProcessors, StrD (CpuUsages(NumberOfProcessors), 3), 1)
SetGadgetItemText (1, NumberOfProcessors, TimeConvert(KernelTimesStart(NumberOfProcessors)), 2)
SetGadgetItemText (1, NumberOfProcessors, TimeConvert(UserTimesStart(NumberOfProcessors)), 3)
SetGadgetItemText (1, NumberOfProcessors, TimeConvert(IdleTimesStart(NumberOfProcessors)), 4)
TimeStart = CurTime
EndProcedure
QueryPerformanceFrequency_ (@Frequency)
QueryPerformanceCounter_ (@TimeStart)
GetProcessorsTimes()
Win = OpenWindow ( #PB_Any , 0, 0, 475, 140, "CPU Usage Multi-Processors" , #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget )
If IsWindow (Win) And CreateGadgetList ( WindowID (Win))
ListIconGadget (1, 10, 10, 455, 120, "CPU" , 75)
AddGadgetColumn (1, 1, "% Usage" , 60)
AddGadgetColumn (1, 2, "Kernel Time" , 100)
AddGadgetColumn (1, 3, "User Time" , 100)
AddGadgetColumn (1, 4, "Idle Time" , 100)
For i=0 To NumberOfProcessors-1
AddGadgetItem (1, -1, "CPU " + Str (i))
Next
AddGadgetItem (1, NumberOfProcessors, "CPU TOTAL" )
SetTimer_ ( WindowID (Win), 1, 1000, @refresh())
Repeat
Select WaitWindowEvent ()
Case #PB_Event_Gadget
Select EventGadget ()
;Case
EndSelect
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
KillTimer_ ( WindowID (Win), 1)
EndIf
-
- Messages : 1554
- Inscription : lun. 24/juil./2006 6:44
- Localisation : vosges (France) 47°54'39.06"N 6°20'06.39"E
Je dirais que c'est mieux. Les quatre processus sembles etre en effet en phase avec
l'occupation des coeurs.
Idem pour le total, qui reste bien autour de 25% lorsque je lance mon petit programme de test.
Seul soucis encore, mes valeur sont toutes à 200 par defaut (donc 225% sur le total lorsque
j'ai lancé mon test...)

l'occupation des coeurs.
Idem pour le total, qui reste bien autour de 25% lorsque je lance mon petit programme de test.
Seul soucis encore, mes valeur sont toutes à 200 par defaut (donc 225% sur le total lorsque
j'ai lancé mon test...)

Force et sagesse...
Ce serait intéressant de coupler ton code à celui de Hi-Toro...
Code : Tout sélectionner
; Obtain CPU power state (XP only) and other useful information (2000 or above)...
; For PB 4...
; *** DEMO REQUIRES DEBUG ON! ***
; Processor Performance Control Policy Structures...
Structure PROCESSOR_POWER_POLICY_INFO
TimeCheck.l
DemoteLimit.l
PromoteLimit.l
DemotePercent.c
PromotePercent.c
Spare.c[2]
AllowDemotion.l
AllowPromotion.l
Reserved.l
EndStructure
Structure PROCESSOR_POWER_POLICY
Revision.l
DynamicThrottle.b
Spare.b[3]
DisableCStates.l
Reserved.l
PolicyCount.l
Policy.PROCESSOR_POWER_POLICY_INFO[3]
EndStructure
Structure MACHINE_PROCESSOR_POWER_POLICY
Revision.l
ProcessorPolicyAc.PROCESSOR_POWER_POLICY
ProcessorPolicyDc.PROCESSOR_POWER_POLICY
EndStructure
Structure PROCESSOR_POWER_INFORMATION
Number.l
MaxMhz.l
CurrentMhz.l
MhzLimit.l
MaxIdleState.l
CurrentIdleState.l
EndStructure
; Processor Performance Control Policy Constants...
#PO_THROTTLE_NONE = 0
#PO_THROTTLE_CONSTANT = 1
#PO_THROTTLE_DEGRADE = 2
#PO_THROTTLE_ADAPTIVE = 3
Dim PowerState.s (3)
PowerState (0) = "No throttling"
PowerState (1) = "Constant throttling"
PowerState (2) = "Throttling according to battery, heat, etc"
PowerState (3) = "Dynamic throttling"
; D e m o . . .
Debug ""
; Power Management API reference:
; http://msdn2.microsoft.com/en-us/library/aa373163.aspx
pwr = OpenLibrary (#PB_Any, "powrprof.dll")
If pwr
; Get functions...
GetActivePwrScheme = GetFunction (pwr, "GetActivePwrScheme") ; Requires 2000 or above
CallNtPowerInformation = GetFunction (pwr, "CallNtPowerInformation") ; Requires 2000 or above
ReadProcessorPwrScheme = GetFunction (pwr, "ReadProcessorPwrScheme") ; Requires *XP* or above
; Get number of CPUs...
GetSystemInfo_ (sys.SYSTEM_INFO)
cpus = sys\dwNumberOfProcessors
; Prepare buffer(s) for information...
buffsize = SizeOf (PROCESSOR_POWER_INFORMATION) * cpus
Dim buffer.PROCESSOR_POWER_INFORMATION (cpus - 1)
; Get CPU information...
CallFunctionFast (CallNtPowerInformation, 11, #Null, #Null, @buffer (0), buffsize)
; Show CPU information...
For cpu = 0 To cpus - 1
Debug "CPU: " + Str (buffer (cpu)\Number)
Debug ""
Debug "Max MHz: " + Str (buffer (cpu)\MaxMhz)
Debug "Current MHz: " + Str (buffer (cpu)\CurrentMhz)
Debug "MHz Limit: " + Str (buffer (cpu)\MhzLimit)
Debug "Max idle state: " + Str (buffer (cpu)\MaxIdleState)
Debug "Current idle state: " + Str (buffer (cpu)\CurrentIdleState)
Debug ""
Next
; Get CPU power state (XP only due to ReadProcessorPwrScheme () call)...
If CallFunctionFast (GetActivePwrScheme, @pwrid)
If ReadProcessorPwrScheme ; Should be Null on < XP!
CallFunctionFast (ReadProcessorPwrScheme, pwrid, @policy.MACHINE_PROCESSOR_POWER_POLICY)
Debug "CPU power state: " + PowerState (policy\ProcessorPolicyAc\DynamicThrottle)
EndIf
EndIf
CloseLibrary (pwr)
EndIf
Debug ""
Quand tous les glands seront tombés, les feuilles dispersées, la vigueur retombée... Dans la morne solitude, ancré au coeur de ses racines, c'est de sa force maturité qu'il renaîtra en pleine magnificence...Jacobus.
-
- Messages : 1554
- Inscription : lun. 24/juil./2006 6:44
- Localisation : vosges (France) 47°54'39.06"N 6°20'06.39"E
Ta représentation est bien celle que j'ai en effet. Quand a l'heure Kernel, c'est en effetGillou a écrit :Si je comprends bien tu vois à peu prêt ça :
CPU0 : 211...
CPU1 : 210...
CPU2 : 220...
CPU3 : 215...
CPU TOTAL : 214...
Et l'heure (Kernel) affichée sur le coté correspond bien à peu prêt au temps depuis que tu as démarré ton pc
bien la duré correspondant au demarrage. Par contre, le total de l'heure du Kernel
fait la somme, et donc dans mon cela multiplie par 4 le temps total depuis demarrage...
Force et sagesse...
@Tmyke
Ok, je vais continuer à chercher, par contre en ce qui concerne le temps kernel total c'est tout a fait logique qu'il soit 4 fois la durée depuis ton démarrage puisque 4 tâches d'une durée égale au temps depuis le démarrage aurait pu s'effectuer, donc on les additionne
au moins un truc qui marche...
@Jacobus
Le code que tu fournis est vraiment intéressant et je crois qu'une fois tout débugguer on pourra faire une appli qui cumulera tout pour en faire une sorte de System Monitor,
Vivement que tout soit débuggué...MDR
Ok, je vais continuer à chercher, par contre en ce qui concerne le temps kernel total c'est tout a fait logique qu'il soit 4 fois la durée depuis ton démarrage puisque 4 tâches d'une durée égale au temps depuis le démarrage aurait pu s'effectuer, donc on les additionne
au moins un truc qui marche...

@Jacobus
Le code que tu fournis est vraiment intéressant et je crois qu'une fois tout débugguer on pourra faire une appli qui cumulera tout pour en faire une sorte de System Monitor,
Vivement que tout soit débuggué...MDR
@Tmyke, une fois le code si dessous chargé pourrais-tu me dire si la colonne nommé (% (25)) en toute logique correspond bien à la division par 4 de la colonne (% Usage).
Encore merci de tests !!!
Encore merci de tests !!!
Structure SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
IdleTime.q
KernelTime.q
UserTime.q
Reserved1.q[3]
EndStructure
#SystemProcessorPerformanceInformation = 8
#SysProcPerfInfoLength = 48
#PROCESS_QUERY_INFORMATION = $400
#HUNDRED_NANOSEC = 10000000
Declare.l cpu_count()
Global Frequency.q, TimeStart.q
Global NumberOfProcessors = cpu_count()
Global Dim CpuInfo.SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION(NumberOfProcessors)
Global Dim KernelTimesStart.d(NumberOfProcessors+1)
Global Dim UserTimesStart.d(NumberOfProcessors+1)
Global Dim IdleTimesStart.d(NumberOfProcessors+1)
Global Dim KernelTimesStop.d(NumberOfProcessors+1)
Global Dim UserTimesStop.d(NumberOfProcessors+1)
Global Dim IdleTimesStop.d(NumberOfProcessors+1)
Global Dim KernelTimesDelta.d(NumberOfProcessors+1)
Global Dim UserTimesDelta.d(NumberOfProcessors+1)
Global Dim IdleTimesDelta.d(NumberOfProcessors+1)
Global Dim CpuUsages.d(NumberOfProcessors+1)
Procedure.l cpu_count() ; Retourne le nombre de processeur
Protected SI.SYSTEM_INFO
GetSystemInfo_ (@SI)
ProcedureReturn SI\dwNumberOfProcessors
EndProcedure
Procedure.s TimeConvert(time.q)
hr.l = Round (time/36000000000, 0)
time = time-(hr*36000000000)
min.l = Round (time/600000000, 0)
time = time-(min*600000000)
sec.l = Round (time/10000000, 0)
time = time-(sec*10000000)
ms.l = Round (time/10000, 0)
ProcedureReturn Str (hr)+ ":" + RSet ( Str (min), 2, "0" )+ ":" + RSet ( Str (sec), 2, "0" )+ ":" + RSet ( Str (ms), 3, "0" )
EndProcedure
Procedure GetProcessorsTimes(start = #True )
Protected Lib
Lib = OpenLibrary ( #PB_Any , "ntdll.dll" )
If Lib
Function = GetFunction (Lib, "NtQuerySystemInformation" )
If CallFunctionFast (Function, #SystemProcessorPerformanceInformation , @CpuInfo(), #SysProcPerfInfoLength * NumberOfProcessors, 0) = 0
If start = #True
KernelTimesStart(NumberOfProcessors) = 0
IdleTimesStart(NumberOfProcessors) = 0
UserTimesStart(NumberOfProcessors) = 0
For i = 0 To NumberOfProcessors - 1
KernelTimesStart(i) = CpuInfo(i)\KernelTime
IdleTimesStart(i) = CpuInfo(i)\IdleTime
UserTimesStart(i) = CpuInfo(i)\UserTime
KernelTimesStart(NumberOfProcessors) = KernelTimesStart(NumberOfProcessors) + CpuInfo(i)\KernelTime
IdleTimesStart(NumberOfProcessors) = IdleTimesStart(NumberOfProcessors) + CpuInfo(i)\IdleTime
UserTimesStart(NumberOfProcessors) = UserTimesStart(NumberOfProcessors) + CpuInfo(i)\UserTime
Next
Else
KernelTimesStop(NumberOfProcessors) = 0
IdleTimesStop(NumberOfProcessors) = 0
UserTimesStop(NumberOfProcessors) = 0
For i = 0 To NumberOfProcessors - 1
KernelTimesStop(i) = CpuInfo(i)\KernelTime
IdleTimesStop(i) = CpuInfo(i)\IdleTime
UserTimesStop(i) = CpuInfo(i)\UserTime
KernelTimesStop(NumberOfProcessors) = KernelTimesStop(NumberOfProcessors) + CpuInfo(i)\KernelTime
IdleTimesStop(NumberOfProcessors) = IdleTimesStop(NumberOfProcessors) + CpuInfo(i)\IdleTime
UserTimesStop(NumberOfProcessors) = UserTimesStop(NumberOfProcessors) + CpuInfo(i)\UserTime
Next
EndIf
EndIf
CloseLibrary (Lib)
EndIf
EndProcedure
Procedure refresh()
Protected CpuTime.d, CurTime.q, DiffTime.d
QueryPerformanceCounter_ (@CurTime)
GetProcessorsTimes( #False )
CpuUsages(NumberOfProcessors) = 0
For i = 0 To NumberOfProcessors - 1
KernelTimesDelta(i) = KernelTimesStop(i) - KernelTimesStart(i)
UserTimesDelta(i) = UserTimesStop(i) - UserTimesStart(i)
IdleTimesDelta(i) = IdleTimesStop(i) - IdleTimesStart(i)
CpuTime = (KernelTimesDelta(i) + UserTimesDelta(i) + IdleTimesDelta(i))
DiffTime = (CurTime - TimeStart) / Frequency
If DiffTime > 0 : CpuTime = ((CpuTime) / (DiffTime)) / NumberOfProcessors : EndIf
CpuUsages(i) = (100 * (1 - CpuTime / #HUNDRED_NANOSEC ))
If NumberOfProcessors = 1 : CpuUsages(i) = 100 + CpuUsages(i) : EndIf
If CpuUsages(i) < 0 : CpuUsages(i) = 0 : EndIf
If CpuUsages(i) > (100/NumberOfProcessors) : CpuUsages(i) = (100/NumberOfProcessors) : EndIf
SetGadgetItemText (1, i, StrD (CpuUsages(i), 3), 2)
CpuUsages(NumberOfProcessors) = CpuUsages(NumberOfProcessors) + CpuUsages(i)
CpuUsages(i) = CpuUsages(i) * NumberOfProcessors
KernelTimesStart(i) = KernelTimesStop(i)
UserTimesStart(i) = UserTimesStop(i)
IdleTimesStart(i) = IdleTimesStop(i)
SetGadgetItemText (1, i, StrD (CpuUsages(i), 3), 1)
SetGadgetItemText (1, i, TimeConvert(KernelTimesStart(i)), 3)
SetGadgetItemText (1, i, TimeConvert(UserTimesStart(i)), 4)
SetGadgetItemText (1, i, TimeConvert(IdleTimesStart(i)), 5)
Next
KernelTimesStart(NumberOfProcessors) = KernelTimesStop(NumberOfProcessors)
UserTimesStart(NumberOfProcessors) = UserTimesStop(NumberOfProcessors)
IdleTimesStart(NumberOfProcessors) = IdleTimesStop(NumberOfProcessors)
SetGadgetItemText (1, NumberOfProcessors, StrD (CpuUsages(NumberOfProcessors), 3), 1)
SetGadgetItemText (1, NumberOfProcessors, TimeConvert(KernelTimesStart(NumberOfProcessors)), 3)
SetGadgetItemText (1, NumberOfProcessors, TimeConvert(UserTimesStart(NumberOfProcessors)), 4)
SetGadgetItemText (1, NumberOfProcessors, TimeConvert(IdleTimesStart(NumberOfProcessors)), 5)
TimeStart = CurTime
EndProcedure
QueryPerformanceFrequency_ (@Frequency)
QueryPerformanceCounter_ (@TimeStart)
GetProcessorsTimes()
Win = OpenWindow ( #PB_Any , 0, 0, 535, 140, "CPU Usage Multi-Processors" , #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget )
If IsWindow (Win) And CreateGadgetList ( WindowID (Win))
ListIconGadget (1, 10, 10, 515, 120, "CPU" , 75)
AddGadgetColumn (1, 1, "% Usage" , 60)
AddGadgetColumn (1, 2, "% (" + Str (100/NumberOfProcessors)+ ")" , 60)
AddGadgetColumn (1, 3, "Kernel Time" , 100)
AddGadgetColumn (1, 4, "User Time" , 100)
AddGadgetColumn (1, 5, "Idle Time" , 100)
For i=0 To NumberOfProcessors-1
AddGadgetItem (1, -1, "CPU " + Str (i))
Next
AddGadgetItem (1, NumberOfProcessors, "CPU TOTAL" )
SetTimer_ ( WindowID (Win), 1, 1000, @refresh())
Repeat
Select WaitWindowEvent ()
Case #PB_Event_Gadget
Select EventGadget ()
;Case
EndSelect
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
KillTimer_ ( WindowID (Win), 1)
EndIf
-
- Messages : 1554
- Inscription : lun. 24/juil./2006 6:44
- Localisation : vosges (France) 47°54'39.06"N 6°20'06.39"E
Salut. Je viens donc de tester ton dernier code, et voici le resultat:
j'ai toujours le meme affichage sur les deux première colonnes (%Usage et %(25) ):
CPU0 100.000 25.0000
CPU1 100.000 25.0000
CPU2 100.000 25.0000
CPU3 100.000 25.0000
CPUTOTAL 100.000
Alors qu'avec une machine avec un proc standart cela fonctionne sans soucis apparent...
j'ai toujours le meme affichage sur les deux première colonnes (%Usage et %(25) ):
CPU0 100.000 25.0000
CPU1 100.000 25.0000
CPU2 100.000 25.0000
CPU3 100.000 25.0000
CPUTOTAL 100.000
Alors qu'avec une machine avec un proc standart cela fonctionne sans soucis apparent...

Force et sagesse...
OK disons que le code que tu viens de tester, j'avais limité à 25% et apparemment tu dois avoir un taux de départ à 50% alors que le proc ne devrait pas pouvoir dépasser 25% ( 100%/Le nombre proc (4) )
Franchement je commence à nager, je vois pas pourquoi ton proc renverrait autant.
Je vais essayer de trouver une doc sur ton proc et sur les api liées au quad core
Franchement je commence à nager, je vois pas pourquoi ton proc renverrait autant.
Je vais essayer de trouver une doc sur ton proc et sur les api liées au quad core
Re, juste pour voir si c'est moi qui fait des conneries, je t'envoi la source de départ au format VB si tu peux la tester, (l'exe est dans le zip au cas ou tu n'aurais pas VB), si tu as pas confiance pour lancer un exe, laisse tomber (je t'en voudrais pas
).
Le lien :
http://lggillou.vbc3.com/Fichier/CPU%20 ... essors.zip

Le lien :
http://lggillou.vbc3.com/Fichier/CPU%20 ... essors.zip