美文网首页
sysbench 测试套使用说明

sysbench 测试套使用说明

作者: 缘觉如来 | 来源:发表于2018-05-03 14:48 被阅读333次

    简介

    sysbench是一套开源的模块化,跨平台,多线程的基准测试工具。

    sysbench可以测试以下系统的性能数据

    • CPU的调度性能
    • 文件系统的IO性能
    • 内存分配和传输速度
    • posix线程的实现性能
    • 数据库服务器性能

    sysbench的测试原理比较简单,sysbench运行指定数量的线程,以并发的形式执行。


    安装

    方式一 :debian仓库安装

    打开终端,执行命令:
    sudo apt-get install sysbench -y

    方式二 :源码安装

    克隆仓库到本地
    git clone https://github.com/akopytov/sysbench.git
    cd sysbench
    手动安装编autoconf工具libtool
    sudo apt-get install -y autoconf libtool
    ./autogen.sh
    ./configure
    如果需要测试mysql数据库的性能,需要安装mysql客户端开发包
    sudo apt-get install -y libmysqlclient-dev
    sudo make && make install


    测试帮助

    安装完成之后就可以进行sysbench的测试了。通用的执行sysbench测试的命令为:
    sysbench [common-options] --test=name [test-options] command

    Common-options和test-options 在后面会详细解释每个options的意思。这里只简短的说明一下每个command的用法。

    prepare :做一些测试环境初始化的动作。比如fileio测试时,在磁盘上创建一些必要的测试文件。
    run:运行--test制定的测试。
    cleanup:清除测试过程产生的临时文件
    help:显示usage。
    同时,用户可以使用命令sysbench help 查看使用说明。


    测试

    CPU性能测试

    打开终端,执行命令,测试CPU性能,CPU测试主要是进行素数的加法运算。在例子中,指定了最大的素数为2000.个人可以根据自己的CPU的性能来适当的调整整数值
    sysbench --test=cpu --cpu-max-prime=2000 run
    测试结果

    >sysbench --test=cpu --cpu-max-prime=2000 run
          sysbench 0.4.12:  multi-threaded system evaluation benchmark
    >
    >Running the test with following options:
    >Number of threads: 1
    >
    >Doing CPU performance benchmark
    >
    >Threads started!
    >Done.
    >
    >Maximum prime number checked in CPU test: 2000
    >
    >
    >Test execution summary:
        total time:                          0.5259s
        total number of events:              10000
        total time taken by event execution: 0.5201
        per-request statistics:
             min:                                  0.05ms
             avg:                                  0.05ms
             max:                                  0.10ms
     >        approx.  95 percentile:               0.05ms
    >
    >Threads fairness:
    >   events (avg/stddev):           10000.0000/0.00
    >    execution time (avg/stddev):   0.5201/0.00
    

    磁盘IO性能测试:

    针对不同的IO 类型有不同的测试选项:

    seqwr 顺序写入
    seqrewr 顺序重写
    seqrd 顺序读取
    rndrd 随机读取
    rndwr 随机写入
    rndrw 混合随机读/写

    混合读写测试:

    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw prepare
    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw run
    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw cleanup
    
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw run
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Running the test with following options:
    Number of threads: 16
    
    Extra file open flags: 0
    128 files, 24Mb each
    3Gb total file size
    Block size 16Kb
    Number of random requests for random IO: 10000
    Read/Write ratio for combined random IO test: 1.50
    Periodic FSYNC enabled, calling fsync() each 100 requests.
    Calling fsync() at the end of test, Enabled.
    Using synchronous I/O mode
    Doing random r/w test
    Threads started!
    Done.
    
    Operations performed:  6149 Read, 4099 Write, 12878 Other = 23126 Total
    Read 96.078Mb  Written 64.047Mb  Total transferred 160.12Mb  (6.593Mb/sec)
      421.95 Requests/sec executed
    
    Test execution summary:
        total time:                          24.2871s
        total number of events:              10248
        total time taken by event execution: 1.7889
        per-request statistics:
             min:                                  0.01ms
             avg:                                  0.17ms
             max:                                 33.09ms
             approx.  95 percentile:               0.04ms
    
    Threads fairness:
        events (avg/stddev):           640.5000/112.66
        execution time (avg/stddev):   0.1118/0.04
    
    deepin@deepin:~/testtools/sysbench-master$ 
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw cleanup
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Removing test files...
    

    顺序写入测试:

    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqwr prepare
    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqwr run
    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqwr cleanup
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqwr prepare
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    128 files, 24576Kb each, 3072Mb total
    Creating files for the test...
    deepin@deepin:~/testtools/sysbench-master$ 
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqwr run
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Running the test with following options:
    Number of threads: 16
    
    Extra file open flags: 0
    128 files, 24Mb each
    3Gb total file size
    Block size 16Kb
    Periodic FSYNC enabled, calling fsync() each 100 requests.
    Calling fsync() at the end of test, Enabled.
    Using synchronous I/O mode
    Doing sequential write (creation) test
    Threads started!
    Done.
    
    Operations performed:  0 Read, 196608 Write, 128 Other = 196736 Total
    Read 0b  Written 3Gb  Total transferred 3Gb  (95.561Mb/sec)
     6115.88 Requests/sec executed
    
    Test execution summary:
        total time:                          32.1472s
        total number of events:              196608
        total time taken by event execution: 72.1188
        per-request statistics:
             min:                                  0.03ms
             avg:                                  0.37ms
             max:                                 38.65ms
             approx.  95 percentile:               0.39ms
    
    Threads fairness:
        events (avg/stddev):           12288.0000/316.63
        execution time (avg/stddev):   4.5074/0.00
    
    deepin@deepin:~/testtools/sysbench-master$ 
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqwr cleanup
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Removing test files...
    

    顺序读取测试:

    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqrd prepare
    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqrd run
    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqrd cleanup
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqrd prepare
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    128 files, 24576Kb each, 3072Mb total
    Creating files for the test...
    deepin@deepin:~/testtools/sysbench-master$ 
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqrd run
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Running the test with following options:
    Number of threads: 16
    
    Extra file open flags: 0
    128 files, 24Mb each
    3Gb total file size
    Block size 16Kb
    Periodic FSYNC enabled, calling fsync() each 100 requests.
    Calling fsync() at the end of test, Enabled.
    Using synchronous I/O mode
    Doing sequential read test
    Threads started!
    Done.
    
    Operations performed:  196608 Read, 0 Write, 0 Other = 196608 Total
    Read 3Gb  Written 0b  Total transferred 3Gb  (7.6301Gb/sec)
    500044.69 Requests/sec executed
    
    Test execution summary:
        total time:                          0.3932s
        total number of events:              196608
        total time taken by event execution: 4.4492
        per-request statistics:
             min:                                  0.01ms
             avg:                                  0.02ms
             max:                                  0.31ms
             approx.  95 percentile:               0.02ms
    
    Threads fairness:
        events (avg/stddev):           12288.0000/457.16
        execution time (avg/stddev):   0.2781/0.01
    
    deepin@deepin:~/testtools/sysbench-master$ 
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=seqrd cleanup
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Removing test files...
    

    随机写入:

    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndwr prepare
    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndwr run
    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndwr cleanup
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndwr prepare
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    128 files, 24576Kb each, 3072Mb total
    Creating files for the test...
    deepin@deepin:~/testtools/sysbench-master$ 
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndwr run
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Running the test with following options:
    Number of threads: 16
    
    Extra file open flags: 0
    128 files, 24Mb each
    3Gb total file size
    Block size 16Kb
    Number of random requests for random IO: 10000
    Read/Write ratio for combined random IO test: 1.50
    Periodic FSYNC enabled, calling fsync() each 100 requests.
    Calling fsync() at the end of test, Enabled.
    Using synchronous I/O mode
    Doing random write test
    Threads started!
    Done.
    
    Operations performed:  0 Read, 10068 Write, 12831 Other = 22899 Total
    Read 0b  Written 157.31Mb  Total transferred 157.31Mb  (2.7681Mb/sec)
      177.16 Requests/sec executed
    
    Test execution summary:
        total time:                          56.8309s
        total number of events:              10068
        total time taken by event execution: 2.1383
        per-request statistics:
             min:                                  0.01ms
             avg:                                  0.21ms
             max:                                 74.61ms
             approx.  95 percentile:               0.04ms
    
    Threads fairness:
        events (avg/stddev):           629.2500/80.13
        execution time (avg/stddev):   0.1336/0.05
    
    deepin@deepin:~/testtools/sysbench-master$ 
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndwr cleanup
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Removing test files...
    

    随机读取测试:

    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrd prepare
    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrd run
    sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrd cleanup
    

    测试结果:

    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrd prepare
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    128 files, 24576Kb each, 3072Mb total
    Creating files for the test...
    deepin@deepin:~/testtools/sysbench-master$ 
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrd run
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Running the test with following options:
    Number of threads: 16
    
    Extra file open flags: 0
    128 files, 24Mb each
    3Gb total file size
    Block size 16Kb
    Number of random requests for random IO: 10000
    Read/Write ratio for combined random IO test: 1.50
    Periodic FSYNC enabled, calling fsync() each 100 requests.
    Calling fsync() at the end of test, Enabled.
    Using synchronous I/O mode
    Doing random read test
    Threads started!
    Done.
    
    Operations performed:  11835 Read, 0 Write, 0 Other = 11835 Total
    Read 184.92Mb  Written 0b  Total transferred 184.92Mb  (7.43Gb/sec)
    486935.60 Requests/sec executed
    
    Test execution summary:
        total time:                          0.0243s
        total number of events:              11835
        total time taken by event execution: 0.2632
        per-request statistics:
             min:                                  0.01ms
             avg:                                  0.02ms
             max:                                  0.15ms
             approx.  95 percentile:               0.02ms
    
    Threads fairness:
        events (avg/stddev):           739.6875/55.84
        execution time (avg/stddev):   0.0164/0.00
    
    deepin@deepin:~/testtools/sysbench-master$ 
    deepin@deepin:~/testtools/sysbench-master$ sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrd cleanup
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Removing test files...
    

    sysbench oltp测试,执行命令,

    创建测试数据库

    mysqladmin create sbtest -uroot -p
    准备测试环境:

    sysbench --test=oltp --oltp-table-size=100000 --mysql-user=root --mysql-password=123456 --num-threads=20 --max-time=120 --max-requests=0 --oltp-test-mode=complex prepare
    

    执行测试:

     sysbench --test=oltp --oltp-table-size=100000 --mysql-user=root --mysql-password=123456 --num-threads=20 --max-time=120 --max-requests=0 --oltp-test-mode=complex run
    

    清理测试环境:

     sysbench --test=oltp --oltp-table-size=100000 --mysql-user=root --mysql-password=123456 --num-threads=20 --max-time=120 --max-requests=0 --oltp-test-mode=complex cleanup
    

    测试结果:

    Deepin测试结果:

    deepin@deepin:~/byte-unixbench/UnixBench$  mysqladmin create sbtest -uroot -p
    Enter password: 
    deepin@deepin:~/byte-unixbench/UnixBench$ sysbench --test=oltp --oltp-table-size=100000 --mysql-user=root --mysql-password=123456 --num-threads=20 --max-time=120 --max-requests=0 --oltp-test-mode=complex prepare
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    No DB drivers specified, using mysql
    Creating table 'sbtest'...
    Creating 100000 records in table 'sbtest'...
    deepin@deepin:~/byte-unixbench/UnixBench$ sysbench --test=oltp --oltp-table-size=100000 --mysql-user=root --mysql-password=123456 --num-threads=20 --max-time=120 --max-requests=0 --oltp-test-mode=complex run
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    No DB drivers specified, using mysql
    Running the test with following options:
    Number of threads: 20
    
    Doing OLTP test.
    Running mixed OLTP test
    Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
    Using "BEGIN" for starting transactions
    Using auto_inc on the id column
    Threads started!
    
    
    iTime limit exceeded, exiting...
    (last message repeated 19 times)
    Done.
    
    OLTP test statistics:
        queries performed:
            read:                            495866
            write:                           175991
            other:                           70456
            total:                           742313
        transactions:                        35037  (291.86 per sec.)
        deadlocks:                           382    (3.18 per sec.)
        read/write requests:                 671857 (5596.60 per sec.)
        other operations:                    70456  (586.90 per sec.)
    
    Test execution summary:
        total time:                          120.0474s
        total number of events:              35037
        total time taken by event execution: 2399.9312
        per-request statistics:
             min:                                 23.64ms
             avg:                                 68.50ms
             max:                                698.93ms
             approx.  95 percentile:             131.95ms
    
    Threads fairness:
        events (avg/stddev):           1751.8500/4.78
        execution time (avg/stddev):   119.9966/0.01
    

    相关文章

      网友评论

          本文标题:sysbench 测试套使用说明

          本文链接:https://www.haomeiwen.com/subject/vvdkrftx.html