Linux: How to put a load on system memory?

后端 未结 12 2076
清酒与你
清酒与你 2021-02-10 07:54

I\'m working on a small function, that gives my users a picture of how occupied the CPU is.

I\'m using cat /proc/loadavg, which returns the well known 3 num

12条回答
  •  野性不改
    2021-02-10 08:41

    while true;
        do openssl speed;
    done
    

    also the stress program will let you load the cpu/mem/disk to the levels you want to simulate:

    • http://weather.ou.edu/~apw/projects/stress/

    stress is a deliberately simple workload generator for POSIX systems. It imposes a configurable amount of CPU, memory, I/O, and disk stress on the system. It is written in C, and is free software licensed under the GPLv2.

    to maintain a particular level of cpu utilization, say 30%, try cpulimit:

    • http://cpulimit.sourceforge.net/

    it will adapt to the current system environment and adjust for any other activity on the system.

    there's also a patch to the kernel for native cpu rate limits here: http://lwn.net/Articles/185489/

提交回复
热议问题