Log thread CPU usage #2035
Replies: 4 comments
-
|
Beta Was this translation helpful? Give feedback.
-
Hi, this is definitely leading into the right direction. But it does not (yet) get me there. Let me elaborate a bit deeper: I am using a simple python script, which is using threading module to create 2 threads in 1 process like this: from threading import Thread
from tqdm import tqdm
import os
def worker():
x = 1.564243525424542
for i in tqdm(range(10000000000), mininterval=1):
x =x +10
x = x / 10
if __name__ == "__main__":
t1 = Thread(target=worker)
t2 = Thread(target=worker)
print(os.getpid())
t1.start()
t2.start() Systeminformer is able to read cpu usage of these threads in a reasonable manner: as python can use only 1 logical processor / process and my machine has 16 of them it makes perfect sense to have ~3% per thread reported. I played with typeperf in order to retrieve the same information: I can receive information of a specific process (given I know the PID) with
something like this:
will give me a list of python threads ... but the performance counters are not unique ... basically every python process has a "\thread(python/0)" and reading the counter will of cause always give me the same result (probably the first it finds)
trying to provide the process id in the performance counter string does also not work unfortunately:
So I still have now way to get performance values of threads if the process name is not unique. Obviously for this toy example I could rename my python execuatble and then iterate through the treads ... but this is not possible for my real usecase ... additionally the tool is giving me quite shaky numbers in the cases it works:
even though the process I am observing has a very static load, basically it is using one logical processor for 100% of the time. Which can be nicely observed in system informer. Not sure why it is dangling around 30 % as it should actually be at 6% (1/16) statically. Don't get confused about the changing PIDs in the thread ... I started the process a couple of times during my experiments ... general statements apply. Any comments an suggestions appreciated. Best Regards |
Beta Was this translation helpful? Give feedback.
-
further looking into this issue I found 2 more tools, that basically do the same thing: unfortunately this gives as unreasonable process an thread cpu utilization readings as typeperf does. 2.) Then I stumbled across a power shell script but also here cpu usage readings don't make sense to me. Seems like systeminformer is doing something right what everybody else is doing wrong ... I would love to have a option to log this infos over time ... |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi, I wonder whether there is any possibility to log a thread cpu usage over a period of time.
Any hints appreciated.
Beta Was this translation helpful? Give feedback.
All reactions