Development environment - test CPU load

Use this command:

cat /dev/urandom | md5sum

 

 

Another method: One line of command makes all CPUs run at 100%

for i in `seq 1 $(cat /proc/cpuinfo |grep "physical id" |wc -l)`; do dd if=/dev/zero of=/dev/null & done

Description:

  • cat /proc/cpuinfo |grep "physical id" | wc -l can get the number of CPUs, we denote it as N.
  • seq 1 N is used to generate numbers between 1 and N
  • for i in `seq 1 N`; is to execute commands in a loop, from 1 to N
  • dd if=/dev/zero of=/dev/null Execute the dd command and output to /dev/null, which actually only occupies the CPU without IO operation.
  • Since N (N is the number of CPUs) dd commands are executed continuously, and the utilization rate is 100%, the scheduler will schedule each dd command to be processed on a different CPU.
  • Eventually realize 100% of all CPU occupancy rate

 

In addition, the end of the above procedure can be used:

  1. Press ctrl + C after fg (because the command is executed in the background)
  2. pkill -9 dd

 

note:

cat /proc/cpuinfo |grep "physical id" |wc -l The purpose of this command is to get the current number of CPUs

But in some systems, the information printed by cat /proc/cpuinfo does not contain "physical id", it may be other values

It is necessary to modify the keywords in grep "physical id" according to the actual printed information

The final effect is to execute this command and print the number of CPUs

Guess you like

Origin blog.csdn.net/Ivan804638781/article/details/100537323