Giter Site home page Giter Site logo

geerlingguy / macbook-pro-battery-test Goto Github PK

View Code? Open in Web Editor NEW
59.0 3.0 4.0 10 KB

Test script to emulate a relatively heavy workload for battery life testing.

License: MIT License

Shell 100.00%
macbook macbook-pro mbp apple battery test battery-life macos mac laptop

macbook-pro-battery-test's Introduction

MacBook Pro Battery Life Test

This repository contains a simple test script to emulate a relatively heavy workload for battery life testing. It downloads a copy of Drupal VM and repeatedly builds and destroys a Virtual Machine running Drupal.

The script does the following, in a loop:

  1. Write a counter, timestamp and the battery percentage (as reported by pmset) to a results file.
  2. Run vagrant up to configure a VM running Drupal on a standard LAMP stack.
  3. Run vagrant destroy -f to destroy the VM.
  4. Wait 10s.
  5. Repeat.

To run the script, you should already have the latest versions of Vagrant and VirtualBox installed.

Note about Vagrant plugins: The author runs the tests without vagrant-cachier installed for consistency's sake. If you use Vagrant regularly, check to make sure you don't have any plugins installed which could affect the consistency of this test using vagrant plugin list!

Other Platforms

This test script should run on any platform which supports Vagrant and VirtualBox, though it's only been tested on macOS, Fedora, and Ubuntu at this time.

Usage

Before running the test script

  1. Disable Sleep: Go to System Preferences > Energy Saver, click on the 'Battery' tab, and drag the 'Turn display off after' slider all the way to 'Never' (alternatively, you could run caffeinate in a separate Terminal window).
  2. Disable Screen Saver: Open System Preferences > Desktop & Screen Saver, then set the Screen Saver to 'Start after: Never'.
  3. Turn up brightness: For consistency's sake, turn up your screen brightness all the way (after the AC power has been disconnected).
  4. Quit all other Applications: To make it a fair comparison. (I also make sure all my Macs are running identical software configurations using the Mac Development Ansible Playbook).

Run the test script

  1. Download project: Download this project to your computer (either download through GitHub or clone it with Git). Important Note: Don't download the project in a 'cloud' directory (e.g. inside Dropbox, Google Drive, or a folder synced via iCloud).
  2. Open Terminal (full screen): Open Terminal.app and put it in full screen mode (so the actual pixels displayed is identical from laptop-to-laptop).
  3. Run Script: Change into this project's directory (cd path/to/macbook-pro-battery-test). Run ./battery-test.sh, and then walk away for a few hours.

After your Mac forces a sleep (when the battery has run out), plug it back in, then check the most recent file in results/ in the project directory.

Results

Results are written to a date-and-timestamped file inside the results folder. This file is in CSV format, so you can open it in Excel, Numbers, Google Sheets, or any other CSV-compatible program and graph the results as needed.

The results file has the following structure (as an example):

Counter Time Battery Percentage
0 2017-01-07 15:58:40 100%
0 2017-01-07 16:10:48 98%
0 2017-01-07 16:17:22 94%
... ... ...

Results of this script's test runs have been posted to the author's blog and a public Google Sheet:

Author

This script was created by Jeff Geerling to run some more formal battery tests on the 2016 Retina MacBook Pro—both with and without Touch Bar—and to see if battery life and performance between the two models (under heavier load) was much different.

macbook-pro-battery-test's People

Contributors

geerlingguy avatar oxyc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

macbook-pro-battery-test's Issues

Vagrant prompts for admin credentials

Issue:

When I run battery-test.sh as a regular user (non-admin), vagrant is prompting me for admin credentials during the destroy process, which blocks the tests:

==> drupalvm: Forcing shutdown of VM...
==> drupalvm: Destroying VM and associated drives...
==> drupalvm: Pruning invalid NFS exports. Administrator privileges will be required...
Password:

Same thing also happens during vagrant up:

$ vagrant up
Bringing machine 'drupalvm' up with 'virtualbox' provider...
==> drupalvm: Importing base box 'geerlingguy/ubuntu1604'...
==> drupalvm: Matching MAC address for NAT networking...
==> drupalvm: Checking if box 'geerlingguy/ubuntu1604' is up to date...
==> drupalvm: Setting the name of the VM: drupalvm.dev
==> drupalvm: Pruning invalid NFS exports. Administrator privileges will be required...
Password:

The impact of this is that the loop fails to complete and it doesn't properly test battery life.

Versions:

$ vagrant -v
Vagrant 1.9.1

Virtualbox 5.1.12 r112440

vagrant-cachier

Did you run the tests with vagrant-cachier installed or no? If you did, it might need to be clarified as well.

Improve README for consistency

After running the test on a couple different laptops, I noticed that I forgot to do a couple things to increase the test-to-test consistency between laptops:

  • Disable the Screen Saver: Open System Preferences > Desktop & Screen Saver, then set the Screen Saver to 'Start after: Never'.
  • Turn up brightness to 100%: This emulates the harshest conditions, e.g. when I'm working in a bright airport terminal.
  • Open Terminal to Full Screen mode: This ensures the screen uses a consistent amount of power from laptop-to-laptop (if there are different desktop images, icons on desktop, etc. then the screen will use very slightly different amounts of power).

Make it work on non-macOS platforms

I'd also like to run the tests on a few other OSes and hardware, just for grins, like my Lenovo T420 and it's double-capacity battery.

Most thing should work the same across most Linux distros or even something like Cygwin or Cmder (though not WSL under Windows, because it's not a full Linux instance), but I think the pmset command would need to be behind a flag.

Drupal install fails on each VM provision in 1.0.0

Currently, the command to remove the drupal folder that's generated by Drupal VM doesn't succeed fully, as there are some settings files which aren't removable by the user running the script.

Since we can't use sudo rm for this command (by default, the sudo timeout of 5m on macOS means the entire battery test would have to be interactive!), we need to figure out a different way of getting rid of the remnants of the drupal folder before the next vagrant up.

For now, it's fine to leave it as-is, since all 1.0.0 test runs will work the same. It's just not quite as perfect an analog to my own heavy workloads, since I install and reinstall Drupal dozens of times in a given day.

Stuck on Task Generate Drupal Project

Hi @geerlingguy

When starting the run first time I am getting

TASK [geerlingguy.drupal : Generate Drupal project with composer package in /tmp/composer-project (this may take a while).] ***

waited for 4 hrs. system is responsive , I can do other tasks.

vagrant --version
2.2.3

./battery-test.sh asking for password

battery-test.sh keep asking for password while it's executing

OSX 10.13.5

anually adding equivalent entries to the hosts file.
Password:

==> macbook_pro_battery_test: [vagrant-hostsupdater] Removing hosts
Password:

Provide recommended Vagrant and VirtualBox versions

One thing to note—if you have a different VirtualBox version installed than the one my current box versions are configured for, it might cause some extra time per build installing updated Guest Additions (if you have vagrant-vbguest installed).

So I'd like to add a recommendation for what versions were used at the time the version was released.

In my case, I'm currently on VirtualBox 5.1.10, but 5.1.12 is the latest release...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.