sysbench

最後更新: 2021-07-14

介紹

Compiled-in tests:

  • fileio - File I/O test
  • cpu - CPU performance test
  • memory - Memory functions speed test
  • threads - Threads subsystem performance test
  • mutex - Mutex performance test
  • oltp - OLTP test

 


Install

 

yum install sysbench             # C7

apt-get install sysbench        # U18

apt-get install sysbench        # buster-backports

 


CPU

 

# With newer version, the --test= option can be omitted

sysbench --test=cpu help

# --cpu-max-prime=N upper limit for primes generator [10000]

sysbench cpu --cpu-max-prime=10000 run

相當於

sysbench cpu run

CPU speed:
    events per second:  1393.03

 


File IO

 

在目錄上建立一堆檔案, 之後再在那些檔案空間上做 IO Test

--file-num

# Default 將會在當前目錄建立 128 個 file

--file-num=128

--file-total-size

# 它們的 Default total size 是 2G

--file-total-size=6G

 * 應該大於現有的 RAM, 否則會被 cache 影響

--file-test-mode

  • seqwr - sequential write
  • seqrewr - sequential rewrite
  • seqrd - sequential read
  • rndrd - random read
  • rndwr - random write
  • rndrw - combined random read/write

--file-io-mode

# sync (DEFAULT), async, fastmmap, slowmma

--file-io-mode=sync

--time

# 測試多久, 預設 10 秒

--time=10

Usage

sysbench --test=fileio --file-num=64 --file-total-size=6g prepare

sysbench 1.0.17 (using system LuaJIT 2.0.4)

64 files, 98304Kb each, 6144Mb total
Creating files for the test...
Extra file open flags: (none)
Creating file test_file.0
...
Creating file test_file.63
6442450944 bytes written in 67.12 seconds (91.54 MiB/sec).

# "--file-num=64 --file-total-size=6g" 要與 prepare 相同

sysbench --test=fileio --file-test-mode=seqwr --file-num=64 --file-total-size=6g --time=300 run

...
Throughput:
    read, MiB/s:                  0.00
    written, MiB/s:               104.90

General statistics:
    total time:                          10.0078s
    total number of events:              110155

Latency (ms):
         min:                                    0.01
         avg:                                    0.09
         max:                                   31.27
         95th percentile:                        0.07
         sum:                                 9923.93
...

sysbench --test=fileio cleanup

Remark

所有 test file 內容都是 "0"

Other Opts

  • --threads=1                  # number of threads to use
  • --file-block-size=16384  # block size to use in all IO operations (16k)
  • --event=0                     # limit for total number of events (指定了--time後就不用設定它)

 


Memory

 

# default 1K

--memory-block-size

# 100G

--memory-total-size

 


 

 

 

 

 

 

 

 

Creative Commons license icon Creative Commons license icon