• linux系统生成负载


    Simulate System Loads
    Sysadmins often need to discover how the performance of an application is affected when the system is under certain types of load. This means that an artificial load must be re-created. It is, of course, possible to install dedicated tools to do this but this option isn’t always desirable or possible.

    Every Linux distribution comes with all the tools needed to create load. They are not as configurable as dedicated tools but they will always be present and you already know how to use them.

    CPU
    The following command will generate a CPU load by compressing a stream of random data and then sending it to /dev/null:

    cat /dev/urandom | gzip -9 > /dev/null
    If you require a greater load or have a multi-core system simply keep compressing and decompressing the data as many times as you need e.g.:

    cat /dev/urandom | gzip -9 | gzip -d | gzip -9 | gzip -d > /dev/null
    An alternative is to use the sha512sum utility:

    sha512sum /dev/urandom
    Use CTRL+C to end the process.

    RAM
    The following process will reduce the amount of free RAM. It does this by creating a file system in RAM and then writing files to it. You can use up as much RAM as you need to by simply writing more files.

    First, create a mount point then mount a ramfs filesystem there:

    mkdir z
    mount -t ramfs ramfs z/
    Then, use dd to create a file under that directory. Here a 128MB file is created:

    dd if=/dev/zero of=z/file bs=1M count=128
    The size of the file can be set by changing the following operands:

    bs= Block Size. This can be set to any number followed B for bytes, K for kilobytes, M for megabytes or G for gigabytes.
    count= The number of blocks to write.
    Disk
    We will create disk I/O by firstly creating a file, and then use a for loop to repeatedly copy it.

    This command uses dd to generate a 1GB file of zeros:

    dd if=/dev/zero of=loadfile bs=1M count=1024
    The following command starts a for loop that runs 10 times. Each time it runs it will copy loadfile over loadfile1:

    for i in {1..10}; do cp loadfile loadfile1; done
    If you want it to run for a longer or shorter time change the second number in {1..10}.

    If you prefer the process to run forever until you kill it with CTRL+C use the following command:

    while true; do cp loadfile loadfile1; done

  • 相关阅读:
    Unity Shader入门精要之 screen post-processing effect
    Unity---关于游戏小包的记录
    计算机基础补充之原码、反码、补码
    C#接口实现技巧之借助第三方
    lua中产生 1
    游戏文本本地化(一)
    xlua修复C#的委托事件的时候,需要提前做好配置
    xlua 实现协程替换Unity中的协程
    C#定义只能处理枚举类型的泛型类型
    C# : 泛型的继承关系实现的一个可以存放不同数据类型的链表
  • 原文地址:https://www.cnblogs.com/zhoubiyu/p/14597993.html
Copyright © 2020-2023  润新知