sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #30595
Re: [Question #262157]: What is the best way to control the CPU load produced by SikuliX?
Question #262157 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/262157
Status: Open => Answered
RaiMan proposed the following answer:
LOL, already thought that you might be more in this direction.
Nevertheless: sometimes I take the chance with a question to write down some general comments.
Might be it helps others.
BTW: thanks for feedback on SikuliX.
Your problem:
In such system specific cases there are only 3 options:
1. find a Python package, that works with Jython or some Java library
2. access the Windows API with some Java JNI/JNA package (e.g. BridJ, that I use), but usage is rather complex
3. find an appropriate Windows command, that reveals the needed information
In this case option 3 is sufficient:
cmd = "wmic path Win32_PerfFormattedData_PerfProc_Process get Name,PercentProcessorTime"
# yields output like:
# process_name cpu_utilization_value_in_%
# example 30
# example1 12
cmdOut = run(cmd) # issue command
# check the command output
info = cmdOut.split("\n") # get the output as list of lines
for line in info:
line = line.strip() # get rid of suttounding whitespace
if line.endswith(" 0"): continue # skip entries having value 0
print line
(name, cpu) = line.split() # get the name and percentage
# and more processing as you like
You might put this into a function.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.