Mac App Review: Sleep Monitor

Sleep Study

Does your MacBook snore? Do Macs … dream?

OK, so it’s not that kind of study. If you suspect that your MacBook has Sleep Apnea, this review won’t help you. (Just for the record I think my Mac Pro suffers from Apnea. It keeps waking up after it’s been put to sleep, but don’t get me started.)

This review covers an application from DssW called Sleep Monitor. If you guessed that Sleep Monitor keeps tabs on your Mac’s energy usage and battery drain, you’d have guessed correctly. DssW bills Sleep Monitor 3 as an app that audits your Mac’s energy usage. To this extent, the app, now in its third version, is very simple and utilizes straight-forward graphics to display battery drainage (and charging) when awake or asleep.

A Sleep Primer

MacBooks sleep in different stages — kind of like people do. There’s normal sleep, which is the sleep your MacBook goes into when you close the lid. Normal sleep is quick to wake up from. Then there’s Safe Sleep where the machine actually shuts off after writing the contents of its memory to disk. If you’ve used Windows, you probably think this sounds a lot like Windows’ hibernate mode. Macs don’t quite work like that. As a user, there’s no way to put a stock MacBook into a Safe Sleep other than to let the battery drain. The Safe Sleep mode is reserved for use by OS X.

Apple introduced Safe Sleep in its MacBooks about 7 years ago. Safe Sleep works by writing the entire contents of your Mac’s memory to the hard disk before the battery drains completely. This is done so that when your battery fully discharges (while sleeping) you don’t lose everything you were doing before you put your machine to sleep. If your battery does completely drain, the next time you plug it in, your MacBook will check the hard drive to read its last state before sleep. It’s literally a snapshot of what was in RAM before total loss of power. This is usually faster than booting up from off and it you don’t lose your work. Smart, right? Safe Sleep does have some caveats though. The first being, it takes a while to save 4 to 8 gigabytes of RAM to even a 7200 RPM hard drive. You may have been told not to jostle your MacBook after closing it until the little white light starts pulsating. The last thing you want to do is jostle your MacBook around while it’s writing the contents of its RAM to the drive!

Enter Sleep Monitor

Anyone who uses a MacBook knows about batteries and battery life. Part of the whole “portable” thing is not having to be tethered to anything for any reason, even an outlet. That’s the way it is for me anyway.

Until the 2nd gen MacBook Air, all the laptops I owned had at best just above adequate battery life. I have a 15” MacBook Pro that I love, but I’m lucky to get 3½ hours of battery life before I have to find an outlet. What’s more disturbing is that even while asleep, it seems to discharge the battery at an alarming rate. Maybe there are other issues with my battery, or maybe it’s because after using a MacBook Air for a while, the MacBook Pro’s battery life seems comparatively short. Now, I don’t know about you, but when I’m using my MacBook, I just want to use it, so outside of letting the screen shut off quicker than when on AC, there’s not a lot I do to save battery. I simply don’t want to worry about it.

With the MacBook Air getting such good battery life when in use (1), the thing I’m curious about now is how much the battery drains when I’m not using it. Can I save more by putting it in “hibernate” versus the usual sleep mode? Is it actually going into a hibernate state (hard to tell on a MacBook Air believe it or not)?

And that’s where Sleep Monitor can enter the picture, because once it’s installed and running, Sleep Monitor begins to monitor your MacBook’s uptime, downtime, and current battery state. This may not sound like a lot, but over time I’ve been able to glean quite a bit of info on my usage habits as well as how fast my 13″ MacBook Air’s (2) battery drains.

The Interface

Sleep Monitor Main Window

Sleep Monitor is a one-window application with a line graph showing the battery percentage that occupies the top third of the app with an event log below it. Clicking the Start button on the top left of the window starts Sleep Monitor 3. It’s important to note that, once started, Sleep Monitor is always running and monitoring in the background even after you quit the application. This is nice because the Sleep Monitor agent running in the background uses fewer resources then the app itself, plus it’s one less app to ⌘-Tab through.

Once you start Sleep Monitor and it’s had the opportunity to run for a while, it will have logged every battery event (charge or discharge) since first starting. It displays this with the line graph at the top and the event list below. The line—orange in color when running on battery and green when charging—flows through colored blocks of blueish purple (asleep) and white (awake). The event log lists the entries in chronological order with each entry corresponding to a point on the line graph. Every time the battery level changes (up or down) Sleep Monitor writes an entry. Obviously this doesn’t happen while the MacBook is sleeping, but it compares the last measurement before sleep with the one at wake. Sleep Monitor also shows the amount of time running as well as the time elapsed since it was last run, which I found interesting.

Holding the mouse over an event entry reveals what was running at the time. Though this is nice, it displays it in a yellow tool tip box. It would be nice to see this displayed in a little better format as well as allow it to be something you can query against. Clicking the graph’s line will take you to the corresponding entry. Hovering the mouse over a point in the graph shows a tool tip displaying “Asleep” or “Awake”. This would be a good spot for a tool tip showing the battery charge state as well as the time and date.

Using Sleep Monitor 3

To test Sleep Monitor, I had this idea it might be better for my battery if I used Mac OS X’s Safe Sleep feature rather than the normal sleep mode where there’s a small amount of power drained from the battery to keep your RAM alive.

I found that starting up from a Safe Sleep state is faster than from a cold start, but from an SSD equipped MacBook Air it appears to be nearly as quick as waking up from normal sleep, so I wanted find out if, in fact, my Mac was actually going into a hibernate sleep (shutting off) and if that was  making a difference in its battery life. As I mentioned before, unlike Windows, the Mac doesn’t offer a hibernate option, so to accomplish this I use a little pref pane app called SmartSleep to force my MacBook Air to go into Safe Sleep rather than normal sleep.

So, what did I find out? What did Sleep Monitor tell me? I’m happy to report that it’s a “yes” to both questions. Yes, I am putting my MacBook Air into a Safe Sleep state each time it sleeps and, yes, I am saving battery drain. In normal sleep over a period of 11 hours, the battery lost 6%. Which doesn’t seem like a lot, but in Safe Sleep over a period of better than 13 hours, the battery fell less than 1%. I thought this was quite revealing and an affirmation of what I had believed (hoped) was happening. Your mileage will vary of course, but it’s nice being able to essentially shut my machine off without losing what I was doing. Again, if you’re a Lion user, this is a little less compelling with its ability to do the same on startup, but still quicker than a cold start on a MacBook Air.

As mentioned above, Sleep Monitor does have a simple interface. It charts a line graph showing the current charge of the battery at a given time as well as your Mac’s current state (sleep or awake). Below the graph it presents a list view for each point on the graph which equates to a percentage up or down in the battery charge. You can use the pop-up menu to view the graph for Today, Yesterday, the Last 7 Days, Last Week (Mon-Sun), the Last Month, or All Time. It does have a Search Field that allows you to filter results when you choose Other in the menu, though I’m not certain what it’s supposed to do. The search field appears to allow you to filter out certain items within the current search results. In addition to the searches listed above, you can also choose Previous Day or Next Day to go back and forward within the time Sleep Monitor was running and gather information. While you can search using the aforementioned search ranges, there’s no apparent way to enter your own custom date range. If there is a way to do this, it isn’t obvious.

Enter AppleScript

Scripts Menu

Before you panic, let me tell I did discover that you can control some of Sleep Monitor 3’s functionality via AppleScript. If you’re not aware of what AppleScript is or how to use it, you can find out more information about it at http://en.wikipedia.org/wiki/AppleScript or https://developer.apple.com/library/mac/#documentation/AppleScript/Conceptual/AppleScriptX/AppleScriptX.html

In a nutshell, AppleScript is a scripting language for the Mac that Apple introduced way back in System 7 and I was really glad to see it make the leap to OS X. AppleScript is one of the treasures of the Mac. It’s not always possible to implement certain functionality in an app, and that’s where AppleScript comes in. Developers can provide an AppleScript dictionary giving users the ability to control the app and have it perform certain functions that are otherwise unavailable. (3) In Sleep Monitor’s case, it allows you to display the graph and event log between any two dates you wish. The Sleep Monitor 3 user guide includes some AppleScript examples to do just that. I took the AppleScript code included in the Sleep Monitor’s User Guide, and modified it to allow basic user input. If you have Sleep Monitor and wish to use this script, all you need to do is download the script and place it in Sleep Monitor’s Scripts folder. You’ll also need open AppleScript Editor and in the Preferences menu check Show Script menu in the menu bar. While in there, you may also want to click the Show Applications scripts at: top checkbox. Doing so will put a little script icon up in the menu bar. This menu contains all of Apple’s provided scripts, but it’s also contextual in that it will display whatever scripts are available for the app you’re using. If there are any, you’ll see them under the menu item with the app’s name. In this case, the SM Date Range script I placed in Sleep Monitor’s scripts folder shows up as a menu item. Running this script will present a dialog box (see below) allowing you to enter a date range or a single (4) date to search on. In this way I have extended Sleep Monitor’s functionality for my own needs.

Below is that code. If you decide to use Sleep Monitor, you can integrate this AppleScript into the app’s scripts folder.

set stdate to getmmddyyyyDate(current date) -- calling the date format subroutine
set temp to display dialog "Enter a date range with dates separated by a dash (e.g. 1/18/2012-1/25/2012). To search the current date, leave as is. To search another date, replace " & stdate & " with a new date." default answer stdate
set text_user_entered to the text returned of temp & "-"
set old_delimiters to AppleScript's text item delimiters

set AppleScript's text item delimiters to {"-"}
try
set date1 to the first text item of text_user_entered
set date2 to the second text item of text_user_entered
set AppleScript's text item delimiters to old_delimiters
on error errMsg number errNum
set date1 to ""
set date2 to ""
end try

if date1 = "" and date2 > "" then
set date1 to date2
end if
if date2 = "" and date1 > "" then
set date2 to date1
end if
if date1 = "" and date2 = "" then
return 0
end if
tell application "Sleep Monitor"
set startDay of visibleSlice to date date1
set endDay of visibleSlice to date date2
end tell
to getmmddyyyyDate(dater) -- gets and returns the current date in the format yyyy-mm-dd
set {month:m, day:d, year:y} to (dater)
tell (m * 100 + d + y * 10000) as string to text 5 thru 6 & "/" & text 7 thru 8 & "/" & text 1 thru 4
end getmmddyyyyDate

An Issue?

There appears to be some sort of bug in Sleep Monitor that causes the background agent to take 99% of the CPU. I have contacted DssW about this and will update this review with what I find out. It should be noted that I have been running Sleep Monitor since the end of December 2011 and this issue only showed up a day ago. Force quitting the sleep agent background process in Activity Monitor will kill it temporarily, because it will respawn itself (since it runs as root) and again run out of control. The only real way to kill it, short of logging in as root, is to reopen the Sleep Monitor app and click the Stop button. Unfortunately, in my case, the background agent had become self-aware and killed the Sleep Monitor app on open. I needed to kill it again in Activity Monitor, then open the app and click the Stop button twice before it stopped singing “Daisy” to me.

Final Thoughts

I’ve played around with Sleep Monitor for a few weeks and was able to verify some things I had wondered about, but would have never really taken the time to look at. Sleep Monitor 3 made it easy to do that. Clearly Sleep Monitor is a simple application from the stand point that it only does one thing: monitor your MacBook’s battery drain & usage. However, because it can start up at login and run in the background automatically, it can compile a lot of data on your Mac’s battery and energy usage over time. In that sense, even if I never used it again, I could fire up the application in the future as a diagnostic tool (e.g. Is the battery drain faster over time? Is there a particular app which causes faster battery drain? etc.) for my battery in times of trouble.

Review Summary

Sleep Monitor

Version: 3.0

Price: $10.99 (special launch price)

Publisher: DssW

Site: www.dssw.co.uk/sleepmonitor

FMEO Rating:

 Rated 4 Macs

System Requirements: Intel Mac desktop or MacBook running Mac OS X 10.6.7 or later.

Strengths:

  • Easy to use
  • Simple interface
  • Inexpensive

Weaknesses:

  • Would like to see the ability to enter custom date ranges (or if this is available, to make it obvious).
  • No way to export data (e.g. as a spreadsheet or as delimited text)
  • Initial .0 release, may have some bugs as noted above.

Update 2/28/12: DssW notes that export of your data IS possible.  In the blog post referenced in the comment below, they say:

One aspect Eric raised was the missing ability to export your data. This is possible to do with Sleep Monitor; you can export all your gathered information using the File > Export… menu item. Sleep Monitor can export your data in RTF, plain text, Word, and XML formats. The plain text export is tab separated, so can be imported directly into a spreadsheet.


  1. I usually average 5+ hours with the battery which is amazing. It’s the first laptop where I don’t pay constant attention to the little battery indicator up on the menu bar.
  2. For this review I ran Sleep Monitor 3 on a mid 2011 13” Core i7 MacBook Air/4 GB RAM/256 GB SSD
  3. Another good example of this is some of the first versions of iTunes. At one time iTunes did not have the ability to show you any duplicates. Sites like Doug’s Scripts wrote AppleScript scripts to find duplicates which worked great.
  4. You can also do the single date within the app by choosing the Jump To menu option.

Comments

  1. sleep monitor says

    Great post!!

    Are there any othey Apps that keeps tabs on your Macbook pro energy usage?

  2. Thanks for posting a link to Eric’s review Graham!

    I added an update to the review to note the ability to Export data from Sleep Monitor.

    Mike

Trackbacks

  1. […] to Eric Erickson, For Mac Eyes Only, for reviewing and recommending Sleep Monitor 3. Sleep Monitor 3 recommended by For Mac Eyes […]