Sysbench安裝與使用

Sysbench安裝與使用

Sysbench安裝


curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | sudo bash
sudo apt -y install sysbench
sysbench --version

img

Sysbench使用

內存測試

查看內存幫助信息

sysbench memory help # 查看內存幫助信息
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

memory options:
    # 用於測試的內存塊大小,默認爲1K。
  --memory-block-size=SIZE    size of memory block for test [1K] 
    # 要傳輸的數據的總大小,默認爲100G。
  --memory-total-size=SIZE    total size of data to transfer [100G]
    # 內存訪問範圍,可以是全局(global)或局部(local),默認爲全局。
  --memory-scope=STRING       memory access scope {global,local} [global]
    # 是否從HugeTLB(大頁內存)池中分配內存,默認爲關閉(off)
  --memory-hugetlb[=on|off]   allocate memory from HugeTLB pool [off]
    # 內存操作類型,可以是讀取(read)、寫入(write)或無操作(none),默認爲寫入。 
  --memory-oper=STRING        type of memory operations {read, write, none} [write] 
    # 內存訪問模式,可以是順序(seq)或隨機(rnd),默認爲順序。
  --memory-access-mode=STRING memory access mode {seq,rnd} [seq] 

執行命令

sysbench memory run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
# 使用了1個線程進行測試,每個線程的隨機數生成器都是基於當前時間初始化的。

Running memory speed test with the following options:
  block size: 1KiB
  total size: 102400MiB
  operation: write
  scope: global
# 內存速度測試選項:每次寫入數據的塊大小爲1KiB,總共寫入了102400MiB的數據。
# 操作類型:寫入操作。
# 範圍:全局範圍內的測試。

Initializing worker threads...
Threads started!
Total operations: 37904989 (3789406.67 per second)
37016.59 MiB transferred (3700.59 MiB/sec)

General statistics:
    total time:                          10.0002s
    total number of events:              37904989
# 總體統計:
# 總時間:測試持續了10.0002秒。
#總事件數:完成了37904989個操作。

Latency (ms):
         min:                                    0.00
         avg:                                    0.00
         max:                                    0.98
         95th percentile:                        0.00
         sum:                                 4551.24

# 延遲(毫秒):
# 最小值:0.00
# 平均值:0.00
# 最大值:0.98
# 95百分位值:0.00
# 總和:4551.24

Threads fairness:
    events (avg/stddev):           37904989.0000/0.00
    execution time (avg/stddev):   4.5512/0.00

# 線程公平性:
# 事件數(平均/標準差):每個線程完成的事件數,平均值爲37904989.0000。
# 執行時間(平均/標準差):每個線程的平均執行時間爲4.5512秒。

CPU測試

查看CPU幫助信息

sysbench cpu help # 查看CPU幫助信息
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

cpu options:
  --cpu-max-prime=N upper limit for primes generator [10000]
 # 質數生成器的上限值,默認爲10000。
 # 通過該選項,您可以調整在CPU測試中生成質數的上限值。更高的上限值會導致更大的計算量,可以用來測試系統在處理更復雜計算任務時的性能表現。
# 執行命令
sysbench cpu --cpu-max-prime=5000 run 
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
# 使用了1個線程進行測試,每個線程的隨機數生成器都是基於當前時間初始化的。

Prime numbers limit: 5000
# 質數上限:5000

Initializing worker threads...
Threads started!
CPU speed:
    events per second:  2548.98
# CPU速度:每秒生成約2548.98個事件

General statistics:
    total time:                          10.0003s
    total number of events:              25495
# 總體統計:
# 總時間:測試持續了10.0003秒。
# 總事件數:完成了25495個事件。

Latency (ms):
         min:                                    0.30
         avg:                                    0.39
         max:                                    1.43
         95th percentile:                        0.51
         sum:                                 9981.24
# 延遲(毫秒):
# 最小值:0.30
# 平均值:0.39
# 最大值:1.43
# 95百分位值:0.51
# 總和:9981.24

Threads fairness:
    events (avg/stddev):           25495.0000/0.00
    execution time (avg/stddev):   9.9812/0.00
# 線程公平性:
# 事件數(平均/標準差):每個線程完成的事件數,平均值爲25495.0000。
# 執行時間(平均/標準差):每個線程的平均執行時間爲9.9812秒。

IO測試

查看文件IO幫助信息

sysbench fileio help # 查看文件IO幫助信息
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

fileio options:
    # 要創建的文件數,默認爲128
  --file-num=N                  要創建的文件數,默認爲128
    # 在所有IO操作中使用的塊大小,默認爲16384
  --file-block-size=N           在所有IO操作中使用的塊大小,默認爲16384
    # 要創建的文件的總大小,默認爲2G
  --file-total-size=SIZE        要創建的文件的總大小,默認爲2G
    # 測試模式 {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
  --file-test-mode=STRING       測試模式 {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
    # 文件操作模式 {sync,async,mmap},默認爲sync
  --file-io-mode=STRING         文件操作模式 {sync,async,mmap},默認爲sync
    # 每個線程要排隊的異步操作數量,默認爲128
  --file-async-backlog=N        每個線程要排隊的異步操作數量,默認爲128
    # 用於打開文件的附加標誌列表 {sync,dsync,direct},默認爲空
  --file-extra-flags=[LIST,...] 用於打開文件的附加標誌列表 {sync,dsync,direct},默認爲空
    # 在這個數量的請求後執行fsync()(0表示不使用fsync()),默認爲100
  --file-fsync-freq=N           在這個數量的請求後執行fsync()(0表示不使用fsync()),默認爲100
    # 每次寫操作後執行fsync(),默認爲關閉(off)
  --file-fsync-all[=on|off]     每次寫操作後執行fsync(),默認爲關閉(off)
    # 在測試結束時執行fsync(),默認爲開啓(on)
  --file-fsync-end[=on|off]     在測試結束時執行fsync(),默認爲開啓(on)
    # 使用哪種同步方法 {fsync, fdatasync},默認爲fsync
  --file-fsync-mode=STRING      使用哪種同步方法 {fsync, fdatasync},默認爲fsync
    # 如果可能,最多合併此數量的IO請求(0表示不合並),默認爲0
  --file-merged-requests=N      如果可能,最多合併此數量的IO請求(0表示不合並),默認爲0
    # 組合測試的讀/寫比率,默認爲1.5
  --file-rw-ratio=N             組合測試的讀/寫比率,默認爲1.5

執行命令

sysbench fileio --num-threads=1 --file-total-size=1G --file-test-mode=rndrw run

WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1                          # 備註:使用了單個線程
Initializing random number generator from current time

Extra file open flags: (none)
128 files, 8MiB each                          # 備註:每個文件大小爲8MiB,共創建了128個文件
1GiB total file size                           # 備註:總文件大小爲1GiB
Block size 16KiB                               # 備註:使用的塊大小爲16KiB
Number of IO requests: 0
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
Initializing worker threads...
Threads started!

File operations:
    reads/s:                      1489.71     # 備註:每秒讀取1489.71次
    writes/s:                     993.14      # 備註:每秒寫入993.14次
    fsyncs/s:                     3183.33     # 備註:每秒執行3183.33次fsync()

Throughput:
    read, MiB/s:                  23.28       # 備註:讀取吞吐量爲23.28MiB/s
    written, MiB/s:               15.52       # 備註:寫入吞吐量爲15.52MiB/s

General statistics:
    total time:                          10.0272s   # 備註:測試總時間爲10.0272秒
    total number of events:              56697      # 備註:總事件數爲56697個

Latency (ms):
         min:                                    0.00   # 備註:最小延遲爲0.00ms
         avg:                                    0.18   # 備註:平均延遲爲0.18ms
         max:                                   20.31   # 備註:最大延遲爲20.31ms
         95th percentile:                        0.41   # 備註:95th百分位延遲爲0.41ms
         sum:                                 9953.23   # 備註:總延遲爲9953.23ms

Threads fairness:
    events (avg/stddev):           56697.0000/0.00   # 備註:每個線程平均事件數爲56697.0000個
    execution time (avg/stddev):   9.9532/0.00        # 備註:每個線程平均執行時間爲9.9532秒

線程測試

sysbench threads help      # 使用sysbench工具執行線程測試,並顯示幫助信息
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3) # sysbench版本信息及所使用的LuaJIT版本信息
threads options:                  # 線程選項:
  --thread-yields=N               # 每個請求要執行的yield次數 [1000]
  --thread-locks=N                # 每個線程的鎖數 [8]

sysbench threads --thread-yields=100 --thread-locks=4 run
 
# `threads`: 指定要運行的測試類型,即線程測試。
# `--thread-yields=100`: 每個請求要執行的 yield 次數爲100次。
# `--thread-locks=4`: 每個線程的鎖數爲4個。
# `run`: 表示執行測試。
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:  # 使用以下選項運行測試

Number of threads: 1  # 線程數:1

Initializing random number generator from current time  # 從當前時間初始化隨機數生成器

Initializing worker threads...  # 初始化工作線程...

Threads started!  # 線程已啓動!

General statistics:  # 總體統計:

    total time:                          10.0002s  # 總時間:10.0002秒
    total number of events:              99093  # 總事件數:99093

Latency (ms):  # 延遲(毫秒):

         min:                                    0.07  # 最小值:0.07
         avg:                                    0.10  # 平均值:0.10
         max:                                    3.91  # 最大值:3.91
         95th percentile:                        0.14  # 95th百分位:0.14
         sum:                                 9946.98  # 總和:9946.98

Threads fairness:  # 線程公平性:
    events (avg/stddev):           99093.0000/0.00  # 事件(平均/標準差):99093.0000/0.00
    execution time (avg/stddev):   9.9470/0.00  # 執行時間(平均/標準差):9.9470/0.00

mutex測試

mutex幫助命令

sysbench mutex help
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

mutex options:  # 互斥鎖選項

  --mutex-num=N   total size of mutex array [4096]  # 互斥鎖數組的總大小 [4096]
  --mutex-locks=N number of mutex locks to do per thread [50000]  # 每個線程執行的互斥鎖數量 [50000]
  --mutex-loops=N number of empty loops to do outside mutex lock [10000]  # 在互斥鎖之外執行的空循環次數 [10000]
sysbench mutex run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:  # 使用以下選項運行測試

Number of threads: 1  # 線程數:1

Initializing random number generator from current time  # 從當前時間初始化隨機數生成器

Initializing worker threads...  # 初始化工作線程...

Threads started!  # 線程已啓動!

General statistics:  # 總體統計:

    total time:                          0.1812s  # 總時間:0.1812秒
    total number of events:              1  # 總事件數:1

Latency (ms):  # 延遲(毫秒):

         min:                                  181.07  # 最小值:181.07
         avg:                                  181.07  # 平均值:181.07
         max:                                  181.07  # 最大值:181.07
         95th percentile:                      179.94  # 95th百分位:179.94
         sum:                                  181.07  # 總和:181.07

Threads fairness:  # 線程公平性:
    events (avg/stddev):           1.0000/0.00  # 事件(平均/標準差):1.0000/0.00
    execution time (avg/stddev):   0.1811/0.00  # 執行時間(平均/標準差):0.1811/0.00
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章