Automating Task manager: Any way to sort process details by CPU?

Ask general questions here.
mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Automating Task manager: Any way to sort process details by CPU?

Post by mrt » Wed Jul 06, 2022 12:50 pm

Hey all,

in case of tests failing I capture also the task manager, and on the 'Details' tab i want to sort all running processes by CPU descending.

But, when task manager opens, it restores the column sorting direction from the last setting,
so a simple click on the CPU column only toggles the sorting direction.

Is there any way to ensure that the CPU column is sorted descending?
I haven't found a way to access the little triangle icon which visually indicates the sorting direction, nor any command line parameter that helps here.

any idea?

thanks!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Automating Task manager: Any way to sort process details by CPU?

Post by odklizec » Wed Jul 06, 2022 1:26 pm

Hi,

The little sorting triangle indeed cannot be traced, but you can use ascending/descending string, available in 'Name' attribute, to detect the actual sorting direction...
TaskManager.png
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Re: Automating Task manager: Any way to sort process details by CPU?

Post by mrt » Wed Jul 06, 2022 1:37 pm

Thanks for reply.

The "overview" on the Processes tab seems to be a bit too high level for me.
My bad, what I was talking about is the Details tab:
2022-07-06 14_36_03-Window.png
Any idea for this?
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Automating Task manager: Any way to sort process details by CPU?

Post by odklizec » Wed Jul 06, 2022 1:47 pm

Hi,

I'm afraid, you are out of luck here? It seems there is no similar information available for this particular tab and header. So the best option is to use Processes tab, instead of Details?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

csaszi89
Posts: 41
Joined: Mon Jan 17, 2022 12:10 pm

Re: Automating Task manager: Any way to sort process details by CPU?

Post by csaszi89 » Fri Jul 08, 2022 11:03 am

Hi,

seems that Task Manager gives no information about the current state of this element.

If you really need to automate this sorting on the UI, I would suggest to try compare bitmaps. Take the bitmap you want to expect and store it somewhere, then you can check whether this bitmap exists runtime or not.
Btw, I would never do such verifications in my tests, they can be very messy and brittle.

I am not into image-based testing mechanism of Ranorex, but this case, it can be useful as well:
https://www.ranorex.com/help/latest/ran ... on-glance/

If you are not forced to use Task Manager UI, you just want to manipulate processes I would rather use the .NET possibilities like Process and PerformanceCounter classes, but this way, you should also write some code:
https://docs.microsoft.com/en-us/dotnet ... mework-4.8
Here is an example of using PerformanceCounter:
https://stackoverflow.com/questions/127 ... pplication

Greetings,
Gyuri

mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Re: Automating Task manager: Any way to sort process details by CPU?

Post by mrt » Fri Jul 08, 2022 11:18 am

Thanks for reply.

Yes, I also avoid image based validation because of their flakyness.

The main purpose is, that if a test fails I want to capture the current state of the system (current CPU load, CPU by process, memory consumption) and therefore the idea came up to just quickly capture screenshots of the task manager.
This way we at least get a rough idea if the system is healthy (and the error may come from some other source).

But i guess for this one use case, an image validation may makes sense, because the task manager always looks the same, rescaling of the window is also unlikely so it may work at least for some time.

thank you! br mrt

homestarssmp
Posts: 3
Joined: Mon Jul 04, 2022 10:44 am

Re: Automating Task manager: Any way to sort process details by CPU?

Post by homestarssmp » Thu Jul 14, 2022 7:26 am

Is Task Manager accurate for CPU usage?
For a while, Task Manager itself would report overall CPU usage greater than 100%.https://www.mazuzee.com/index.php?route ... th=90_309 Because that's counterintuitive even to people who understand the concept of “utility,” Task Manager now caps the numbers it reports at 100%. That ends up further distorting what it reports.