|Tip 145||Stress Test Your Mac’s CPU|
If your Mac has been experiencing random crashes, you might want to run a CPU stress test. This will load the processor to 100 percent, and you’ll therefore be able to determine whether it’s faulty or, more likely, whether the cooling system is faulty.
There are various ways of stress-testing a Mac, but the easiest way is as follows. Before starting, be sure to save any open files and close any unnecessary applications. If you’re using a portable Mac, attach the power cord.
Before starting, find out how many processor cores your Mac has. Unless you’re using a Mac Pro desktop system, the answer will be either two or four. To see a quick trick to view the number of cores in the system, check out Tip 135, Watch CPU Load and Activity—just view the number of bars in the CPU performance graph; each represents a core of your CPU.
Open a Terminal window (open Finder, select the Applications list, and then in the list of applications double-click Terminal within the Utilities folder), and type the following at the command prompt:
yes > /dev/null
Then hit Command+T to open a new tab in the Terminal window, and type the command one more time. If you have a four-core processor, repeat the step twice again so that a total of four tabs are open and running the command. If your computer has eight cores, then, yes, you’ve guessed: you’ll need to do this eight times in total so that Terminal is running the command within eight tabs.
The yes command merely creates a stream of characters, but it does so as quickly as it can, to the extent that it soon consumes all the available processing power. Elements after the command direct the output of the yes command to /dev/null, which is like a black hole in the system that consumes as much data as is thrown at it.
Terminating the Test
Wait for a few minutes. You’ll probably hear your computer’s fans start to spin. This is normal, as is the computer getting hot. You might also find the computer becomes a little sluggish when responding to your interaction.
If the computer hasn’t crashed after five minutes, terminate the test by closing the Terminal window (don’t worry about any warning that doing so will terminate currently running apps). If your Mac crashes or freezes up before you terminate the test, it’s very likely your computer has a fault that requires repair.