G
Guest
Hi,
I need to be able to read the amount of processor time a thread has taken
up. So far I've found the following methods open to me:
1) Find the relevant ProcessThread in the current process'
ProcessThreadCollection and read the TotalProcessorTime.
2) Find the PerformanceCounter for the Thread category that relates to the
current thread, and use the NextSample() method to read the processor time
value. (I think this is pretty much what the first method is doing under the
hood anyway)
The problem is, both of those approaches are too slow for me, as I need to
find the value many times in quick succession (I'm using this to find out the
performance cost of methods)
From what I can tell about the PerformanceCounter approach, it re-gets *all*
the performance counter information for all the running threads and processes
every time I call NextSample, which isn't ideal. Is there any way just read
the value for the performance counter instance I'm actually interested in?
Cheers,
Mike
I need to be able to read the amount of processor time a thread has taken
up. So far I've found the following methods open to me:
1) Find the relevant ProcessThread in the current process'
ProcessThreadCollection and read the TotalProcessorTime.
2) Find the PerformanceCounter for the Thread category that relates to the
current thread, and use the NextSample() method to read the processor time
value. (I think this is pretty much what the first method is doing under the
hood anyway)
The problem is, both of those approaches are too slow for me, as I need to
find the value many times in quick succession (I'm using this to find out the
performance cost of methods)
From what I can tell about the PerformanceCounter approach, it re-gets *all*
the performance counter information for all the running threads and processes
every time I call NextSample, which isn't ideal. Is there any way just read
the value for the performance counter instance I'm actually interested in?
Cheers,
Mike