Please keep in mind, that I'm working with a laptop processor. So, when
I put the laptop in Laptop/Portable mode, the processor drops to a
Dynamic 50%. Meaning that for all normal applications, a 2.16ghz dual
core processor will drop to 1.08ghz, meaning .54 ghz each core. (540).
Some other CPU apps on the net can see this. Even the windows built-in
perfmon.msc can see this. Even some of the code already posted here
has been able to detect this, in debug mode in PB. But after creating an
exe, it flys back to full power.
?
Code: Select all
Declare AppendFile(FileName.s, String.s)
Global Fn = 99
Enumeration 1
#Window_frm_main
EndEnumeration
#WindowIndex=#PB_Compiler_EnumerationValue
Enumeration 1
;Window_frm_main
#Gadget_frm_main_txt_main
EndEnumeration
#GadgetIndex=#PB_Compiler_EnumerationValue
Procedure.l Window_frm_main()
If OpenWindow(#Window_frm_main,212,145,192,45,"CPU Speed Recorder",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
If CreateGadgetList(WindowID(#Window_frm_main))
TextGadget(#Gadget_frm_main_txt_main,10,10,130,25,"DATA")
SetGadgetFont(#Gadget_frm_main_txt_main,LoadFont(#Gadget_frm_main_txt_main,"@Arial Unicode MS",14,0))
HideWindow(#Window_frm_main,0)
ProcedureReturn WindowID(#Window_frm_main)
EndIf
EndIf
EndProcedure
Procedure.q GetCycleCount()
!rdtsc
ProcedureReturn
EndProcedure
Procedure CPUSPEED()
Protected A.q
Protected B.q
A = GetCycleCount()
Sleep_(100)
B = GetCycleCount()
ProcedureReturn (B-A) / 100000
EndProcedure
Procedure AppendFile(FileName.s, String.s)
If OpenFile(Fn, FileName)
FileSeek(Fn, Lof(Fn))
WriteStringN(Fn, String)
CloseFile(Fn)
EndIf
EndProcedure
Procedure Tick()
dData.s = FormatDate("%hh:%ii:%ss", Date())
cData.s = Str(CPUSPEED())
finalData.s = dData + " - " + cData
; AppendFile("cpu.log", finalData)
Debug finalData
SetGadgetText(#Gadget_frm_main_txt_main, cData)
EndProcedure
If Window_frm_main()
quitfrm_main=0
SetGadgetText(#Gadget_frm_main_txt_main, "**")
SetTimer_(WindowID(#Window_frm_main), 1, 1000, @Tick())
Repeat
EventID =WaitWindowEvent()
MenuID =EventMenu()
GadgetID =EventGadget()
WindowID =EventWindow()
Select EventID
Case #PB_Event_CloseWindow
If WindowID=#Window_frm_main
quitfrm_main=1
EndIf
Case #PB_Event_Gadget
Select GadgetID
EndSelect
EndSelect
Until quitfrm_main
KillTimer_(WindowID(#Window_frm_main), 1)
CloseWindow(#Window_frm_main)
EndIf
End
- np