How to create a CPU spike with a bash command

后端 未结 23 1219
小蘑菇
小蘑菇 2020-11-30 16:11

I want to create a near 100% load on a Linux machine. It\'s quad core system and I want all cores going full speed. Ideally, the CPU load would last a designated amount of

23条回答
  •  感动是毒
    2020-11-30 16:54

    Here is a program that you can download Here

    Install easily on your Linux system

    ./configure
    make
    make install
    

    and launch it in a simple command line

    stress -c 40
    

    to stress all your CPUs (however you have) with 40 threads each running a complex sqrt computation on a ramdomly generated numbers.

    You can even define the timeout of the program

    stress -c 40 -timeout 10s
    

    unlike the proposed solution with the dd command, which deals essentially with IO and therefore doesn't really overload your system because working with data.

    The stress program really overloads the system because dealing with computation.

提交回复
热议问题