Jump to content
Fivewin Brasil

Obter percentual desempenho CPU [RESOLVIDO]


emotta

Recommended Posts

Seguindo o norte dado pelo Gilmer consegui desenvolver a funcao a partir de um exemplo vbscript. 

Segue o codigo pra quem precisar:

Function u_Teste()

MsgStop(GetCPUUsage())

Return

Static FUNCTION GetCPUUsage()

   local oList, oProc
   Local nCpu := 0
   Local oWmi

   oWmi     := WmiService()
   
   oList    := oWmi:ExecQuery( "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor" )
  
   for each oProc in oList
        If "TOTAL" in Upper(oProc:Name)
            nCpu += Val(oProc:PercentProcessorTime)
        EndIf
   next

return nCpu

 

Link to comment
Share on other sites

 

Seguindo o norte dado pelo Gilmer consegui desenvolver a funcao a partir de um exemplo vbscript. 

Segue o codigo pra quem precisar:


Function u_Teste()

MsgStop(GetCPUUsage())

Return

Static FUNCTION GetCPUUsage()

   local oList, oProc
   Local nCpu := 0
   Local oWmi

   oWmi     := WmiService()
   
   oList    := oWmi:ExecQuery( "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor" )
  
   for each oProc in oList
        If "TOTAL" in Upper(oProc:Name)
            nCpu += Val(oProc:PercentProcessorTime)
        EndIf
   next

return nCpu

 

Emotta  boa tarde

O que a função WmiService() faz ?  ela não foi colocada ai 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...