Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CPUMon.dll - Win98 problem
Message
 
 
À
23/09/2004 11:55:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00941363
Message ID:
00945516
Vues:
21
>>>>>Hello Josh (and everyone else)
>>>>>
>>>>>i have used your CPUMon() and it runs very nicly! i have tested it on Windows XP where i encounter no problems. however, i tested it today on a Windows 98 computer and it would not run. i get the error: "...Unknown Com Status Code". the registration with RegSvr32.exe is successfull.
>>>>>
>>>>>i can not figure out what the problem is. do you have an idea?
>>>>>
>>>>>Thanks for all your help in advance!
>>>>
>>>>Hi Gunnar, I have a liitle routine that extracts CPU utilization from HKEY_PERF_DATA (which is not visible in RegEdit) would you like me to send it to you?
>>>
>>>
>>>Hello Houston.
>>>
>>>Do You think/know if this is available from Win98 on up? if yes, i would appreaciate this very much.
>>>
>>>thanks for your help!
>>
>>Not sure about Win98 I've never used it other than occasionally helping friends (aka subsidizing Micro$oft) but it shouldn't be hard to test - I've just e-mailed a zip file containing the source code.
>
>Hello Houston.
>
>Got your e-mail last night at home, tried it on my vfp 6 sp 5 WinXP Sp 1 machine, doesn't work.
>
>the _screen.cation shows "***". so maximized the screen, and added "? Value" to see what is actually beeing passed. i got a real big number (don't remember exactly) something like 200,000 or so.
>
>any ideas?

Hi Gunnar, I happen to have an XP laptop with me at the moment so I will have a look at it on that, will probably have to use my VFP 7 CD though (lost my VFP 6 CD in Denver Colorado back in 98 or 99! The code hasn't changed in a long time, to the best of my recollection.

Basically the routine takes sucessive snapshots of HKEY_PERFORMANCE_DATA - this is a monster piece of encoded data (still an understatement), from which the number of elapsed clock cycles used by the System Idle Process (single threaded) is determined. The difference in successive values (delta) gives you an accurate measure of CPU clock cycles used by all other processes. i.e. if two successive readings from the System Idle Process are identical, then 100% of the clock cycles were used by other processes - i.e. your system is CPU bound. The math (in theory) is trivial.

From CodeProject.com i found the following:
The cpu usage counter is of type PERF_100NSEC_TIMER_INV which has the following calculation:

100*(1-(X1-X0)/(Y1-Y0))
  X - CounterData
  Y - 100NsTime
  Time base - 100Ns
Nothing new here from my perspective, I thought this was what I was doing:
iPreviousCounter = 0
iPrevious100Time = 0
DO WHILE LASTKEY() # 32
	*************************************************
	cRegValue = fGetRegValue( "238" ;
			, 1024 * 4 ;
			, HKEY_PERFORMANCE_DATA )
	*************************************************
	IF cRegValue = "ERROR"
		EXIT
	ENDIF

	iPerf100Time = fStrToInt( SUBSTR( cRegValue, 73, 8 ))
	iDeltaTime = iPerf100Time - iPrevious100Time

	iCounter = fStrToInt( SUBSTR( cRegValue, iCounterOffset, 8 ))
	iDeltaCounter = iCounter - iPreviousCounter

	? 100 * ABS( 1 - ( iDeltaCounter / iDeltaTime ))
	
	iPreviousCounter = iCounter
	iPrevious100Time = iPerf100Time
ENDDO
I checked that the index into the HKEY_PERFORMANCE_DATA is still 238. I wrote the code Summer 2000 and was probably using Windows 2000 Pro - so what is bizarre is that it no longer works on my Win2KPro SP4. I am seeing the same numbers as you. Maybe the iCounterOffset has changed and I am no longer calculating it correctly.

Division takes precedence over substration, right???

I'll get back to you shortly.
censored.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform