轉載:https://baijiahao.baidu.com/s...mysql
測試cpu:
3個線程,30000上限的素數,執行:
sysbench cpu --cpu-max-prime=30000 --threads=3 --time=30 run
不一樣CPU對比,當線程和素數個數必定:相同時間,比較event;相同event,比較時間;時間和event都相同,比較stddev(標準差)。sql
結果:
sysbench 1.0.15 (using system LuaJIT 2.0.5)
Running the test with following options:
Number of threads: 2 #線程個數
Initializing random number generator from current time
Prime numbers limit: 20000 #素數上線
Initializing worker threads...
Threads started!
CPU speed:
events per second: 633.14 #全部線程平均每秒完成event的個數
General statistics:
total time: 30.0024s #總共消耗的時間
total number of events: 18997 #全部線程完成的event個數
Latency (ms):
min: 3.11 #完成1次event的最少耗時
avg: 3.16 #全部event的平均耗時
max: 8.80 # 完成1次event的最多耗時
95th percentile: 3.25 #95%次event完成的時間
sum: 59995.90 #全部線程的時間綜合
Threads fairness:
events (avg/stddev): 9498.5000/5.50 #平均每一個線程完成envet的次數,後一個值是標準差
execution time (avg/stddev): 29.9980/0.00 #平均每一個線程平均耗時,後一個值是標準差
stddev(標準差): 在相同時間內,多個線程分別完成的素數計算次數是否穩定,若是數值越低,則表示多個線程的結果越接近(即越穩定)。該參數對於單線程無心義。dom
轉載:https://www.jianshu.com/p/899...
測試mysql:
sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=my_test_db --mysql-user=root --mysql-password=111111 --table_size=500000 --tables=1 --threads=100 --events=100000 --report-interval=10 --time=0 prepareide
若是執行的時候提示FATAL: Cannot find benchmark 'oltp_read_write.lua': no such built-in test, file or module
那就找到oltp_read_write.lua,進入他的目錄中,再執行以上命令。測試
若是執行的時候命令行提示「Can not connect to MySQL server. Too many connections」
說明鏈接數超限了,進入mysql中,修改最大鏈接數
mysql -u root -p
首先查看當前的最大鏈接數,
show variables like 'max_connections';
修改
set global max_connections=1000;
這個狀況同理max_allowed_packet
設置好後,再執行以上命令,其中最後的參數能夠分別爲prepare、run、cleanui