LogCPU — An Efficient Load Monitor for Mac OS X  

LogCPU is a simple, very efficient load monitor for MacOS X.


The LogCPU Window
The LogCPU Window


Download: LogCPU-20120403.app.zip

Features:

The Logarithmic Display


Another example (on a 2-core machine)
Another example (on a 2-core machine)


Both scales in the LogCPU graph are logarithmic. The vertical scale (demarcated by the several horizontal lines, each labeled at the right end) shows the amount of activity measured in units of CPU cores. For example if you have a Core 2 Duo CPU and your computer is about 50% busy, the load will be near the line labeled "1", indicating that 1 CPU worth of computing power is in use. Your computer's maximum is indicated by a thicker horizontal line. In this example, the "2" line is drawn a little thicker to indicate that you have 2 CPU cores.

The horizontal scale is time, demarcated by a number of vertical lines indicating moments in time, with the current moment in time at the right end of the scale. Each line is labeled with a number, and the fundamental units of time (minute, hour, day, etc.) are indicated by a slightly larger number "1" and a letter. Reading from right to left, the labels are:

10, 30: seconds

1m: 1 minute

2, 3, 5, 7, 10, 15, 20, 30, 40: minutes

1h: 1 hour

90: 90 minutes (1.5 hours)

2, 3, 4, 6, 8, 12, 16: hours

1d: 1 day

36: 36 hours (1.5 days)

2, 3, 4: days

1w: 1 week

10: 10 days (about 1.4 weeks)

2, 3: weeks

1m: 1 month

45: 45 days (about 1.5 months)

2, 3, 4, 6, 9: months

1y: 1 year

18: 18 months (1.5 years)

2, 3, 4, 5, 7, 10, 15, 20: years

Labels going out to 20 years might seem excessive, but there are a lot of Macs that stay in use for periods of 5 years or more. At this writing (in 2014) I have a Power Mac G5 system with the "Tiger" 10.4 system and an 8-core Mac Pro running 10.6 "Snow Leopard"; each has accumulated a bit over 5 years of cumulative uptime. Its LogCPU display has 5.5 years of data. LogCPU itself was created in July 2004.

Window Display Modes

There are three choices, which affect how the LogCPU load monitor window interacts with your frontmost application. You can also hide the LogCPU program entirely:

option blocks view? blocks mouse clicks?
Always Clickable yes yes
Always Visible yes no
Normal no no
(Hidden) no no

Always Clickable

The window stays in front all the time, regardless of what application you are in, and clicking on the window makes LogCPU the frontmost application. (This is similar to the behavior of the CPU Monitor window in Apple's "Activity Monitor" application.)

Always Visible

The window stays in front all the time, regardless of what application you are in, but any clicks inside it go to your application, not to LogCPU. This allows you to leave the LogCPU display visible at all times without it interfering your your mouse activity.

In this mode, you can only move or resize the LogCPU window when LogCPU is the frontmost application. (Choose LogCPU from the Dock to make it the frontmost.)

Normal

The LogCPU window behaves like any other window: It goes behind other windows when you switch applications, and you click in it to make LogCPU the frontmost applciation.

(Hidden)

The LogCPU application can also be hidden in the normal way, using the "Hide LogCPU" command from LogCPU's "File" menu, or by holding down the option key while clicking on another application's window.

This is useful for keeping the record without cluttering your display. While hidden, LogCPU continues to monitor the CPU activity and its display will reflect that activity if/when you un-hide it.

Transparency and Auto-Fading

Regardless of which mode you select, the LogCPU window is transparent. When you move the mouse inside the LogCPU window, its transparency increases, making it easier to see whatever is behind it. When you mvoe the mouse back out, the transparency returns to normal.

The Data File

LogCPU stores the CPU load data and your settings (window position, size and display mode) in a file called "com.mrob.logcpu.txt", which is placed in the directory "Preferences", in your home "Library" directory. (This is the directory where most applications save preferences and settings.)


History

LogCPU began in the early 1990's as an X Windows configuration for the Sun SPARCstation, in which several CPU load meter icons were placed in a row, each with a different timescale and each partly overlapping the next, so as to make a quasi-logarithmic graph.

I moved to Linux, and then eventually to Mac OS X. I madn't bothered writing my own perftool for Linux, and by the time I got to Mac I missed it so much I used it as an exercise for learning how to make an app for the Mac that uses Cocoa and Quartz drawing APIs.


Footnotes

1 : To measure the CPU usage of programs, I use the time command from a shell prompt in a Terminal window. Here are three examples:

sh-3.2$ time top   real 0m12.644s user 0m0.082s sys 0m0.488s sh-3.2$

Here I ran the top program, itself a UNIX text-only tool, to monitor the system, after 12 seconds I quit the program. The output shows that the program used 0.488 seconds of CPU time for asking the system to do things (mainly reading the table of information about all running tasks, and sending text output to the terminal), and 0.082 seconds for its own activity (sorting the data and formatting it as text). This adds up to 0.57 sec of CPU usage over a period of 12.644 sec (the "real" elapsed time), which means it used 4.5% of one CPU.

sh-3.2$ time '/Applications/Utilities/Activity Monitor.app/Contents/MacOS/Activity Monitor'   real 0m38.080s user 0m0.196s sys 0m0.065s sh-3.2$

Doing the same test on a program that provides a graphical interface — in this case, Activity Monitor. I had only one Activity Monitor window open, the little "CPU History" window, sized down to a width of 280 and a height of 230 pixels. After letting it run 38 seconds I used its "Quit" menu to quit, and the shell's time command then displayed the numbers. These numbers are a lot better than the top tool: It used 0.065+0.196=0.261 of CPU time over the course of 38 seconds, or 0.68% of one CPU (less than 1 percent).

Dashboard widgets are more difficult to measure in this manner. However, since they are Javascript programs being interpreted by WebKit, they are inherently less efficient than the above two examples and LogCPU, all of which are compiled.

sh-3.2$ time /Applications/LogCPU.app/Contents/MacOS/LogCPU   real 0m28.589s user 0m0.104s sys 0m0.041s sh-3.2$

Doing the same test on LogCPU. I ran it for 28.6 seconds, it used 0.104+0.041=0.145 seconds of CPU time, for a percentage of 0.51% (about half of one percent, and just a little less than Activity Monitor).


Robert Munafo's home pages on HostMDS   © 1996-2017 Robert P. Munafo.
aboutcontact    mrob    mrob27    @mrob_27    mrob27
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. Details here.

This page was written in the "embarrassingly readable" markup language RHTF, and was last updated on 2017 Feb 02. s.11