Stress Test a Mac by Maxing Out CPU

Oct 2, 2012 - 25 Comments

If you want to completely peg CPU to stress test a Mac, turn no further than the Terminal. Using the command line you can easily max out all CPU cores and induce huge load on a Mac, making it easy to determine things like what temperature the processor reaches under heavy load, if fans are working properly, how loud fans get, what battery life is like under immense workload, and other technical aspects that can be helpful for troubleshooting purposes. Though it’s a technical process, it’s quite simple to do and we’ll explain everything.

Stress test a Mac by maxing out CPU

How to Stress Test a Mac

To max out the Mac CPU we’ll use the command line tool called “yes”, which basically does nothing except repeat the word “yes” at such speed that it consumes all available processor resources. Generally speaking, each instances of “yes” will max out a single thread on a single CPU core. This means if you have a dual core Mac with a hyperthreaded processor, you’ll need to have at least four different instances of “yes” running to put full load onto the CPU.

To begin, launch Terminal, and you may want to watch the UI-based task manager Activity Monitor so you can easily observe the CPU load and system resources.

When ready to stress test the Mac, type the following command:

yes > /dev/null &

That sends one instance of ‘yes’ into the background, but to load up the CPU you’ll want to have more than one running. Either repeat the process by hitting up arrow and return to run another several instances, or throw a group onto a single line like so:

yes > /dev/null & yes > /dev/null & yes > /dev/null & yes > /dev/null &

You’ll quickly discover in Activity Monitor or top that the processor is getting hit hard.

When finished, in the same terminal window type “killall yes” into the command line to kill all instances of the yes command. You’ll see something like this:

$ killall yes
[1] Terminated: 15 yes > /dev/null
[2] Terminated: 15 yes > /dev/null
[3]- Terminated: 15 yes > /dev/null
[4]+ Terminated: 15 yes > /dev/null

You’ll also see all instances of “yes” drop from the process list in Activity Monitor. If not, there’s probably a typo in there somewhere.

Unless you have a valid reason to do this, you’re better off not randomly running “yes”, since it obviously causes performance issues until it stops running.

For some assistance, the video below demonstrates the entire process from start to finish:

For those wondering, this works in all versions of Mac OS X and even linux as well, so you can stress test any Mac ever made this way. In fact, as long as there is a command line that is unix based, you could run the ‘yes’ command to stress test a Mac CPU by using this approach.

Be sure you quit and kill the ‘yes’ commands when finished stress testing the Mac, as otherwise the CPU usage will remain high and the fans will undoubtedly go on full speed shortly.

.

Related articles:

Posted by: William Pearson in Command Line, Mac OS, Tips & Tricks, Troubleshooting

25 Comments

» Comments RSS Feed

  1. Kevin says:

    Works like a charm, use it to drive out all the ants trying to hibernate in my mac

  2. tpee says:

    I just used this to drain the battery of my van. Cause i wanted to simulate the most power the latop could take, and how long ;P cheers

  3. iPreferOranges says:

    You can use Prime95. It’s used by Windows guys to stress test their CPUs but is also available for Mac. The program is designed as a collaborative effort to find prime numbers but can also be used to stress test the CPU. I used it for my Windows PC, and was glad it was also available for OSX. The CPU shows the running process using 350% percent CPU (wtf) and it’s working the fans hard.

  4. Steffan Dall says:

    Thanks a lot man, having a shoddy mac at the moment from start 2012 – so it’s under pressure quickly. ;)

  5. Dave says:

    I extended this idea to warm up my MacBook Air in the winter. I use the following script, saved as cpu.command. It automatically checks fan speed, and the script turns itself off when the fan reaches that speed.

    #!/bin/bash
    yes > /dev/null &
    yes > /dev/null &
    yes > /dev/null &
    yes > /dev/null &

    cpu=0
    io=0
    while [ $io -lt 25 ]
    do
    echo $cpu $io
    read _ cpu < <(sysctl machdep.xcpm.cpu_thermal_level)
    read _ io < <(sysctl machdep.xcpm.io_thermal_level)
    sleep 10
    done

    killall yes
    exit;

  6. DirkP says:

    Correction to my previous post, I meant the memory test for chips, not the stress test. If my comment could be posted in the proper web page, thank you.

  7. DirkP says:

    Tried installing on my 2010 iMac and got a warning that the version of the test was incompatible with my system ( Now using El Capitan)and might damage my susytem, create a void in space, and cause Trump to win. Will look for a newer version

  8. pj says:

    This is the best thing I have ever seen, it’s useful and an easy way to stress test a Mac processor. Thanks!

  9. that tech guy says:

    did you know that if you want to see how many yesses are being produced you can just type the command: yes and terminal will fill up with the letter y,
    but if you don’t want it to continuously say:
    y
    y
    y
    y
    just enter yes then before pressing enter type in the word you want to fill terminal with

  10. Igor Pavlov says:

    This doesn’t make computer “struggling” though because it distributes the load to fit 100% CPU. Sometimes you need to see what happens if computer is really suffering and has to deal with overload.

  11. andy says:

    It has a practical application. I am stuck at ORD airport overnight. I have no luggage. I only have a T-shirt. It’s freezing. I used this to turn my Macbook into a heater and I’ve been cuddling it all night. A lifesaver.

    *THANKS!!*

  12. sean says:

    this doesn’t really test the performance of the system due to the process you are opening not requiring a lot of power. try doing something like, opening 64 world of warcraft. i have seen many systems on a slightly lower spec for half the price perform well doing this. if your feeling adventurous then go for a very cpu intensive game like arma 2 days mod. that will show the true potential of the mac.

  13. in a small town... says:

    Thought to test a new (unopened, in box) Late 2012 MINI
    quad-core 2.3GHz server prior to fully accepting it, since
    there still is time to send back this ‘clearance’ item bought
    direct from Apple online. Not sure if I’d use it as Server, &
    could not get an exacting answer from Apple (store, main
    support, or other; by phone from AK) & so don’t trust it
    to be able to run the system I hope was shipped in it.

    Since there is little opportunity to tell, & they aren’t saying
    it was the desire to NOT run Yosemite, and to be able to
    upgrade RAM (to 16GB) and later add SSD/HDD upgrade
    is why I initially chose this. It has two 1-TB HDDs.

    Apple could not tell me the OS X version it shipped with.
    I was closer to knowing by use of online Lookup service
    of the serial number (from invoice) than their Experts.

    Anyway, I have a week to ship it back or to to their only
    Store in my state to hand it over (for re-credit to card.)
    I could not get a rise out of the Store staff, the only time
    I was there and walked through slow. Figure I must have
    caught them in a Zen moment, meditating on iDevices,
    as they were looking into touch-pad/screen products &
    never did look up. If I had an iPhone, I’d have called them
    while standing in the Store, to see if anyone looked up.

    A surprise, for my first time in an Apple Store, yet I’ve
    owned over 300 Macs, most second hand; repaired and
    donated almost all of them in restored condition. You
    almost can’t do that now in newest w/ soldered parts…!

    Thank you for your consideration & a reply…
    ~in a small town…
    kenai mts, alaska

  14. Brent says:

    Well, it worked and it didn’t. Heh. It maxed out all the cores, but even after 10 minutes, it did not rev up the fans any more than a teency bit beyond normal.

    My computer has a fluttery fan and I was trying to see if revving them up might A. Fix it or B. Tell me which one is the culprit.

  15. n/a says:

    This was fun to do on a mac pro 8-core. I maxed out all the cores

  16. NA says:

    I just tested my macbook pro retina. Worked as stated just wanted to warm the CPU up after spilling small amount of tea on the keyboard! biggest yikes moment of my life, never drink next to a laptop… especially a macbook worth around £2000

  17. Mel Alton says:

    Thanks, this is really useful for testing out your cpu heatsink and cooler. Start one yes process per core (including hyperthreads) and use something like the Temperature Monitor app to see how hot the cpu gets over time.

    I have a hackintosh built with an i7-3770 and an aftermarket cooler, and I wanted to see how it performed. The i7-3770 has 4 cores and 4 hyperthreads, so I fired up 7 yes processes, then started the activity monitor to watch the cpu usage (88%, since I also had browsers open) and used Temperature Monitor to see how the cooler did.

  18. Chris E says:

    I saw this elsewhere sometime ago, and wondered then what kind of practical application this could have. It’s interesting in and of itself, but I don’t see what real world use it actually has.

    • jch says:

      Before fsck got its “-y” option, “yes | fsck” was often a good idea. There are other programs that have similar prompting behaviour.

      Oh, and “yes no | fsck” might sometimes be a good idea.

      I think yes dates back to Unix Edition 6. There are lots of programs that have little use by themselves but are designed specifically to be combined with something else. Unix is Lego for computers.

      • Rob says:

        I did this at University, I wrote a command that spawned itself twice. I managed to bring down one of the main University servers before I had a chance to stop it.

    • Bob says:

      Software developers can use this to try to reproduce bugs that only occur under load.

  19. jch says:

    No, not really. You can measure the ability of the OS to start processes, but its not a measure of anything useful.

    You also don’t need yes for this: “while :; do :; done &” is slightly more CPU intensive and does involve any system calls so it does nothing faster :)

  20. Mathew says:

    This could be used as a benchmarking tool of sorts couldn’t it? If you somehow timed how long it took to execute however many yeses? Just a thought.

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site