1

Suppose we have one CPU with 2 cores. I seek dynamic scheduling information such as Processes, IO time, IDLE Time, System Time as allocated time specific cores as opposed to aggregated or averaged to a multi core CPU.

Below I have prepared a command but it is giving above information on CPU level and not on core level.

sh-3.2# top -l 15 | grep -i "Processes" | tail -2

Processes: 387 total, 2 running, 385 sleeping, 1677 threads

Processes: 386 total, 2 running, 384 sleeping, 1672 threads
6
  • 1
    According to this answer you can't. macOS "does not export interfaces that identify processors or control thread placement"
    – lx07
    Dec 4 '19 at 10:31
  • 1
    I'd be interested to know what your end goal is for this information.
    – benwiggy
    Dec 4 '19 at 10:53
  • @lx07 That is a misunderstanding. Chandrakant wants to get information about CPU usage per core. The answer you've linked says that you cannot control which CPU core a thread is run on (this is normally known as thread affinity). It's two different things.
    – jksoegaard
    Dec 4 '19 at 13:21
  • @jksoegaard you could be right - the question was way too soft if we’re going to talk about thread affinity as opposed to averaged workload metrics. I tried to sharpen the question. Let’s see what OP actually requests
    – bmike
    Dec 5 '19 at 10:19
  • Chandrakamt - it would help if you specify one actual Mac CPU you care about in your example for top and a specific macOS version.
    – bmike
    Dec 5 '19 at 10:22
2

You can install the program htop from Homebrew, which will give you this information.

When you have Homebrew installed, run the following command to install:

brew install htop

Afterwards you can run the program like this:

htop

If you go into the Setup menu by typing S and select Display Options, you can enable detailed CPU information. The CPU usage bar then displays information about the CPU usage, system (i.e. kernel) time, io time, etc.

4
  • thanks. but above command will give core specific utilization only and not idel time, IO time, System time. is there any mac api expose to get all core specific information. Dec 5 '19 at 6:20
  • 1
    That information is available in the program... I have detailed how to enable the display of it in the setup menu...
    – jksoegaard
    Dec 5 '19 at 8:22
  • @nohillside - you put an edit to type S for setup menu. For me (version 2.2.0 compiled today from source not via homebew) setup is F2 while s invokes strace.
    – lx07
    Dec 5 '19 at 10:18
  • 2
    @lx07 lower-case triggers strace, upper-case setup :-) See github.com/hishamhm/htop/blob/master/htop.1.in, line 108
    – nohillside
    Dec 5 '19 at 10:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .