User Tools

Site Tools


ubuntu:cpu:create_100_cpu_load

Ubuntu - CPU - Create 100% CPU Load

To stress test and benchmark certain key aspects of it including CPU performance.


Install Stress or Stress-ng

sudo apt install stress 

or

sudo apt install stress-ng

NOTE: stress-ng is a newer version of stress that ships in with extra features.


Impose 100% CPU Load

Run stress or stress-ng.

sudo stress-ng --cpu 4 -v --timeout 30s

NOTE: where

  • –cpu: Specifies the number of cores.
  • -v: Enables verbose mode.
  • –timeout: Specifies the time after which the command will terminate.

Check CPU usage

top

Other methods to create 100% CPU load

yes > /dev/null &

NOTE: This only imposes 100% load on a single core.

To impose this against multiple cores, then run the command multiple times to exhaust all the CPU power:

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

NOTE: To terminate the Linux background jobs created by the above commands:

killall yes

Another method to produce 100% CPU load usage

dd if=/dev/zero of=/dev/null

To fully utilize all the cores on your system, run the following command:

fulload() { dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null & }; fulload; read; killall dd

NOTE: The number of the above command in the function should be equal to the number of cores (for example 4 in this case).


ubuntu/cpu/create_100_cpu_load.txt · Last modified: 2022/05/10 19:55 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki