Stress Test a Mac by Maxing Out CPU

Oct 2, 2012 - 7 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

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:

Thanks to TJ for the tip idea

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

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

7 Comments

» Comments RSS Feed

  1. 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.

  2. 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 :)

  3. 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.

  4. 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.

  5. 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

  6. n/a says:

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

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

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