多線程基準測試工具,支援 CPU、內存、I/O、線程、互斥鎖、數據庫(OLTP)等測試。數據庫測試為核心用例。
| 特性 | 0.4 版本 | 0.5+ 版本 |
|---|---|---|
| 數據庫測試模式 | --test=oltp | Lua 腳本 --test=oltp.lua |
| 多表支援 | 單表 | 多表 |
| 實時統計 | 無 | 支援 |
| 自定義邏輯 | 硬編碼 | Lua 腳本可擴展 |
--oltp-test-mode=complex # simple/complex/nontrx/sp
--oltp-table-size=10000 # 測試表行數
--oltp-table-name=sbtest # 表名
--oltp-range-size=100 # 範圍查詢大小
--oltp-point-selects=10 # 點查詢數
--oltp-simple-ranges=1 # 簡單範圍查詢
--oltp-sum-ranges=1 # SUM 範圍查詢
--oltp-order-ranges=1 # ORDER BY 範圍
--oltp-distinct-ranges=1 # DISTINCT 範圍
--oltp-index-updates=1 # 索引更新數
--oltp-non-index-updates=1 # 非索引更新數
--oltp-auto-inc=on # 使用自增主鍵
--oltp-connect-delay=10000 # 連接後延遲(微秒)
--oltp-user-delay-min=0 # 請求間最小延遲
--oltp-user-delay-max=0 # 請求間最大延遲
--db-driver=mysql
--mysql-host=localhost
--mysql-port=3306
--mysql-user=sbtest
--mysql-password=
--mysql-db=sbtest
--mysql-table-engine=innodb # myisam/innodb/bdb/heap/ndbcluster/federated
--mysql-engine-trx=auto # yes/no/auto
--mysql-ssl=off
--num-threads=16 # 併發線程數
--max-requests=0 # 總請求數上限(0=無限)
--max-time=300 # 最大運行時間(秒)
--report-interval=10 # 中間報告間隔(秒)
--forced-shutdown=off # 超時後強制關閉等待時間
--rand-type=special # 隨機分布: uniform/gaussian/special/pareto
sysbench --test=oltp --oltp-table-size=100000 \
--mysql-host=192.168.1.100 --mysql-user=root --mysql-password=xxx \
--mysql-db=test --num-threads=16 prepare
sysbench --test=oltp --oltp-table-size=100000 \
--mysql-host=192.168.1.100 --mysql-user=root --mysql-password=xxx \
--mysql-db=test --num-threads=16 --max-time=300 --report-interval=10 run
sysbench --test=oltp --mysql-host=192.168.1.100 --mysql-user=root --mysql-password=xxx --mysql-db=test cleanup
--report-checkpoints 定時導出完整統計