SysBench 是一個基于 LuaJIT 的可編寫多線程基準測試工具。它最常用于數據庫基準測試,但也可用于創建不涉及數據庫服務器的任意復雜工作負載。
特性:
- 提供大量的速率和延遲的統計數據,包括延遲的百分比和柱狀圖。
- 即使有成千上萬的并發線程,開銷也很低。sysbench 能夠每秒產生和跟蹤數以億計的事件。
- 通過在用戶提供的 Lua 腳本中實現預定義的鉤子,可以輕松創建新的基準。
- 也可以作為一個通用的 Lua 解釋器,只需在你的腳本中用
#!/usr/bin/sysbench替換#!/usr/bin/lua。
sysbench的基本命令格式為:
sysbench –test=< test-name> [options]… < command>
sysbench [general-options]... --test=<test-name> [test-options]... command
General options: #通用選項
--num-threads=N number of threads to use [1] #創建測試線程的數目。默認為1.
--max-requests=N limit for total number of requests [10000] #請求的最大數目。默認為10000,0代表不限制。
--max-time=N limit for total execution time in seconds [0] #最大執行時間,單位是s。默認是0,不限制。
--forced-shutdown=STRING amount of time to wait after --max-time before forcing shutdown [off] #超過max-time強制中斷。默認是off。
--thread-stack-size=SIZE size of stack per thread [32K] #每個線程的堆棧大小。默認是32K。
--init-rng=[on|off] initialize random number generator [off] #在測試開始時是否初始化隨機數發生器。默認是off。
--test=STRING test to run #指定測試類型。
fileio
cpu
memory
threads
mutex
--debug=[on|off] print more debugging info [off] #是否顯示更多的調試信息。默認是off。 --validate=[on|off] perform validation checks where possible [off] #在可能情況下執行驗證檢查。默認是off。
--help=[on|off] print help and exit #幫助信息。 --version=[on|off] print version and exit #版本信息。
--report-interval --指定每多少秒在屏幕上輸出一次結果
--日志選項
--verbosity=N --日志級別,默認為3,5=debug,0=只包含重要信息
Compiled-in tests: #測試項目
fileio - File I/O test #IO
cpu - CPU performance test #CPU
memory - Memory functions speed test #內存
threads - Threads subsystem performance test #線程
mutex - Mutex performance test #互斥性能測試
oltp - OLTP test # 數據庫,事務處理
Commands:
測試的步驟
prepare:測試前準備工作(生成測試需要的數據);
run:進行性能測試
cleanup:測試后刪掉測試數據
help version
See 'sysbench --test=<name> help' for a list of options for each test. #查看每個測試項目的更多選項列表