Sometimes, stress testing a computer can be a very useful thing. For example, if you have a faulty hardware, say a hard disk drive that is having performance issues, then you can run disk I/O intensive tests to see whether it is stable or not.
Or, if you have just overclocked your hardware (CPU, GPU, RAM …) and want to make sure that it won’t make your computer unstable, before applying those changes permanently, then stress testing is among the best ways of knowing that also (or for evaluating the capability of your PC in general).
Anyway, if you use Ubuntu and prefer a tool with a GUI, then you can use ‘lbench’. It has a simple user interface and very easy to use, and is primarily a benchmarking tool. But, if you are okay with using the command-line, then you can also try ‘Stress’.
It lets you put stress on your:
*. Disk Drive (only supports write tests).
It can not stress other hardware such as the GPU though. You can also delay the starting of the stress tests and make it automatically exit after running for a certain amount of time (in seconds) as well.
Remember, ‘Stress’ is not actually a benchmarking utility, as it does not give you any speed related outputs (like ‘lbench’ does), but is only a utility that lets you stress your computer. Still, you can use it as a work load generator, for while benchmarking other utilities, such as an I/O scheduler, as mentioned above too.
If interested, you can install it in Ubuntu 12.10 Quantal Quetzal, 13.04, 12.04 Precise Pangolin, 11.10, 10.10 and 10.04 by using the below command in your Terminal window.
sudo apt-get install stress
How to use it?
You can use ‘Stress’ to stress the above mentioned hardware individually or you can stress them all at the same time too.
Stressing the CPU
If you want only to stress the CPU, then you can use it in the below format (on your Terminal window, of course).
stress -c 1
Depending on the type of your CPU, make sure to replace ‘1‘ accordingly. For example, if you have a CPU with four cores and would like to stress them all, then you should be using the below command.
stress -c 4
You can also enter a number, higher than the available CPU cores for adding a lot more stress on the CPU as well. In other words, if I put 50 individual processes to stress my CPU (‘stress -c 50‘), rather than using 4 processes, it will make the OS more unstable.
Note: You can cancel (exit) ‘Stress’ anytime by pressing ‘Ctrl’ + ‘c’ keys or by closing the Terminal window.
Stressing the Memory (RAM)
Let’s say that I wanted to stress my 4GB RAM module using three processes, with each about 256MiB in size (by default). Then I’ll use the below command.
stress -m 3
You can again replace ‘3‘ with the number of processes to be used, plus, can also change the size of the processes by using the ‘--vm-bytes …’ attribute.
So if I wanted to use 4 process with each sizing around 300MiB, then I’ll use the below command.
stress -m 4 --vm-bytes 300M
Note: However, for stressing your RAM, the CPU also has to do a lot of work as well. And as a result, if the used processes were more or equal to the available cores, then they will use 100% of your CPU power.
Stressing the Disk Drive
If you want to stress the disk drive only, then use the below command.
stress -d 1
‘1‘ represents the number of processes that will be used to stress your disk drive. Again, you can replace this number accordingly. By default, ‘Stress’ uses 1GB file size for each process (you use the ‘--hdd-bytes’ argument for changing that), so make sure your have enough free space left before running this test.
For stressing my HDD with 2 processes, with each sizing around 512MB, I can use the below command.
stress -d 2 --hdd-bytes 512M
Note: Unlike with the RAM stress test, HDD stress test does not require a lot of CPU usages.
Stressing CPU, RAM and HDD simultaneously
If I wanted to stress the CPU, RAM and the HDD at the same time, then I can use it in the below format.
stress -c 4 -m 2 -d 1
As you can see, in this instance, ‘Stress’ will stress the CPU using four processes, RAM will be stressed using 2 processes (each sizing around 256MiB) and the disk will be stressed with a process that is about 1GB in size.
Setting up a timeout
‘Stress’ also lets you run these tests for a chosen time frame. Let’s say that I wanted to run the above test, only for 40 seconds, then I’ll simply add the ‘-t’ argument and the new command will look like the below one.
stress -c 4 -m 2 -d 1 -t 40s
After running for 40 seconds, it will exit automatically.
You can also use the ‘-t’ argument while running other individual tests as well. Its manual contains all these details. You can use the below command for reading it.
But please remember that, stressing your hardware unnecessarily is not recommended as it can easily damage them. So use it only, when it is absolutely necessary.