views:

1317

answers:

11

I often program outside away from power, how can I extend the battery life in my laptop to let me program longer without having to "return to base"

Specifically for a MacBook Pro.

+1  A: 

To extend the battery life per session, reduce brightness, turn off WiFi and Bluetooth if possible, and run as few programs (and as low CPU intensive programs) as possible.

To extend the overall life of the battery, keep it plugged in as much as possible. The fewer cycles, the better the battery's maximum capacity will be.

Matthew Schinckel
A: 

@Niyaz

and this is?

http://stackoverflow.com/questions/34215/what-are-the-best-alternatives-to-notepad

My laptop is a tool I use for programming. I need the battery to last so I can continue to program when I don't have access to power, and as such tips on improving battery life would be helpful.

Matthew Watson
+12  A: 

The edited version of this is probably OK (thank you for editing the question to make it programmer-centric, at least a little!)

I wrote two articles measuring power draw on laptops, you can infer a lot from the numbers:

http://www.codinghorror.com/blog/archives/000562.html

http://www.codinghorror.com/blog/archives/001099.html

Summary.. when you're on battery:

  1. Don't do anything with 3D graphics (gaming, etc)
  2. Avoid using DVDs
  3. Turn down the screen brightness 1 or 2 notches
  4. Avoid CPU intensive web pages or programs

One advantage of the "battery saver" power modes is that they effectively throttle the CPU, which is still the largest power consumer in a laptop. So use those!

Jeff Atwood
I started using the screen brightness one middle of last week and I've noticed an improvement :)
Martin Clarke
I thought the screen was the largest consumer of power. Am I wrong?
William Brendel
@William, screen and CPU are the largest consumers, but CPUs reduce their power consumption dynamically, so they both can be :)
Mehrdad Afshari
Then followed by the HD and the CD/DVD
Unkwntech
+2  A: 

I've been coding on my macbook pro for over a year now, and by far the most significant factor is the screen brightness.

The next significant factor is the age of your battery.

Of course, running CPU-intense operations is also a drain.

Side tip : For those mac users like me who never log out - If you're using file vault, you actually aren't reclaiming disk space from your deleted files in file vault until the next time you log out while your laptop is plugged in . Good to know.

Tyler
+1 for the tip limiting HD reads/writes will help alot.
Unkwntech
A: 

At least on my Precision M65, I have noticed intensive CPU utilization when it gets too hot (poor ventilation), and since CPU usage is directly proportional to batter life, that should be avoided. Make sure that you are working with your laptop so that it has plenty of ventilation and it doesn't get too hot.

Vaibhav
+6  A: 

Quit everything possible, including applications running in the menu bar. Turn the screen brightness down as far as possible. Turn Airport (wifi) and Bluetooth off. Don't use the DVD drive. Try do avoid doing CPU or graphics-card intensive stuff. Obvious, sleep the machine when you're not using it for short periods of time, and either "deep sleep" (see aliases at end of comment) or shut the machine down if you're not going to use it for an hour or more.

In ~/.profile add the following:

# Laptop sleep/hibernate thingy. on == "deep sleep", off == "quick sleep"
alias hibernateon='sudo pmset -a hibernatemode 1'
alias hibernateoff='sudo pmset -a hibernatemode 0'

Then run hibernateon to go in to "deep sleep" (where the contents of RAM are written to the disc, and the machine uses practically no power), or hibernateoff to return to the default sleep behaviour (where it starts up very quick, but uses a bit of power to keep data in RAM).

dbr
+3  A: 

If you are under Un*x you can also use the powertop(1) program to analyze your laptop's power consumption. It is sufficiently smart to make suggestions of its own, such as disabling Bluetooth.

lindelof
powertop is for linux only, last I checked.
Daniel Papasian
OSX is a BSD so it's likely available.
Unkwntech
+3  A: 

I have a MacBook Pro and use it all the time. I went through a lot of batteries on my old powerbook, so I decided to record monthly stats on my battery life and from that, developed usage/charging patterns which seems to maximise battery capacity retention over the battery's lifetime. I still comfortably get around 3- 3.5 hours on full charge, with full screen brightness and a VM running, even though my battery is nearly at 400 charge cycles.

Here's how:

First thing to realise is that the battery will rapidly lose capacity if it is kept at 100% charge, and in high temperatures. Optimal charge for retaining capacity is supposedly 40%, therefore:

  • monitor your battery and keep it between 30% - 50%, this can simply be done by plugging and unplugging the adaptor. (I haven't found a good utility to do this, I'm not sure if it is possible for software to disconnect the battery from the charger. A household timer switch might be useful)
  • as posted above, make sure it doesn't get too hot. I sit near an air conditioner. Metal surfaces are good, they conduct heat away. There are some fans you can sit your machine on if you don't mind the embarrassment. Luckily the penryn macs run a lot cooler than the previous models.

Your battery will need recalibrating from time to time:

  • Plug in and fully charge.
  • Stay fully charged, for two hours or more.
  • Disconnect and use up all battery power.
  • Sleep for five hours.
  • Reconnect and stay connected until fully charged.

The next thing to note is that old batteries are good as UPSs. Hang on to them and use them like that. Buy a new battery (really new, not one that has been hanging around in a shop), charge it 50%, store it in a bag in the fridge. It will hold its capacity very well for a long time in this state. When you need it, take it out and let it warm up in a towel, to avoid condensation problems, before charging it.

Doing this you are using the old battery to extend the life of the new one.

Remember of course that macs are designed to be able to change battery while sleeping.

The new macs have a built in battery that supposedly can go 1000 cycles, and hold a lot more charge. Lets hope this technology will find its way into replaceable batteries in the future.

Regarding actual daily usage - I find on my machine with its low power LED backlight, the main battery eater is the CPU. So I monitor CPU using Activity Monitor. Its easy for processes to run away unnoticed when you have more than 1 CPU. Don't bother with let HDDs spin down. It takes more energy to spin them up again quickly than to simply leave them spinning for 30 mins or so.

FYI mine is an early 2008 MacBook pro 17 inch.

+1  A: 

Installing a solid state drive gave me ~30mins extra too.

Koen Bok
+1  A: 

I'm pretty sure that running code from RAM (i.e., making a virtual RAM drive) saves battery too - just like using a solid state drive does. Only thing is, RAM is probably a lot faster.

Dmitri Nesteruk
Not to mention cheaper.
Unkwntech
A: 

The abutting affair to agenda is that old batteries are acceptable as UPSs. Hang on to them and use them like that. Buy a fresh array (really new, not one that has been blind about in a shop), allegation it 50%, abundance it in a bag in the fridge. It will authority its accommodation absolute able-bodied for a continued time in this state. Back you allegation it, booty it out and let it balmy up in a towel, to abstain abstract problems, afore charging it.

Doing this you are application the old array to extend the activity of the fresh one.

Remember of advance that macs are advised to be able to change array while sleeping.

The fresh macs accept a congenital in array that allegedly can go 1000 cycles, and authority a lot added charge. Lets achievement this technology will acquisition its way into dispensable batteries in the future. http://goo.gl/h1PF Regarding absolute circadian acceptance - I acquisition on my apparatus with its low ability LED backlight, the capital array eater is the CPU. So I adviser CPU application Activity Monitor. Its accessible for processes to run abroad disregarded back you accept added than 1 CPU. Don't bother with let HDDs circuit down. It takes added activity to circuit them up afresh bound than to artlessly leave them spinning for 30 mins or so.

uweul
I adviser augmented anguish leashings.
ergosys