sysbench測試軟體

cccgw發表於2008-12-15

sysbench是一款測試工具

主要包括以下幾種方式的測試:
1
cpu效能
2
、磁碟io效能
3
、排程程式效能
4
、記憶體分配及傳輸速度
5
POSIX執行緒效能
6
、資料庫效能(OLTP基準測試)現在sysbench主要支援 MySQL,pgsql,oracle 3種資料庫

下載安裝包.

[@more@]

我這裡只對主機做一些測試

tar zxf sysbench-0.4.8.tar.gz
cd sysbench-0.4.8
./configure –without-mysql

make

make install

比如我的 MySQL 喜歡自己安裝在 /usr/local/mysql 下,則按照以下方法編譯:

/configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib && make && make install當然了,用上面的引數編譯的話,就要確保您的 MySQL lib目錄下有對應的 so 文件,假如沒有,能夠自己下載 devel share 包來安裝。另外,假如想要讓 sysbench 支援 pgsql/oracle 的話,就需要在編譯的時候加上引數
--with-pgsql

--with-oracle
2個引數預設是關閉的,只有 MySQL 是預設支援的。

測試的時候注意thread數大於兩倍CPU數,測試檔案大小大於5倍記憶體大小。

拿兩臺機器,test18CPU16G記憶體)和test23CPU8G記憶體)來做測試

1、 cpu效能測試
sysbench --test=cpu --num-threads=32 --cpu-max-prime=90000 run
cpu
測試主要是進行素數的加法運算,在上面的例子中,指定了最大的素數為 90000

root :/root>#sysbench --test=cpu --num-threads=32 --cpu-max-prime=90000 run

sysbench v0.4.8: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 32

Doing CPU performance benchmark

Threads started!

Done.

Maximum prime number checked in CPU test: 90000

Test execution summary:

total time: 26.4945s

total number of events: 10000

total time taken by event execution: 837.0154

per-request statistics:

min: 0.0208s

avg: 0.0837s

max: 1.6919s

approx. 95 percentile: 0.3208s

Threads fairness:

events (avg/stddev): 312.5000/3.98

execution time (avg/stddev): 26.1567/0.25


2
、執行緒測試
sysbench --test=threads --num-threads=512 --thread-yields=100 --thread-locks=2 run

thread-locks小於執行緒數除以2lock越少,處理時間越長。

test1: sysbench --test=threads --num-threads=512 --thread-yields=100 --thread-locks=2 run

sysbench v0.4.8: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 512

Doing thread subsystem performance test

Thread yields per test: 100 Locks used: 2

Threads started!

Done.

Test execution summary:

total time: 2.5360s

total number of events: 10000

total time taken by event execution: 1276.9943

per-request statistics:

min: 0.0003s

avg: 0.1277s

max: 0.6007s

approx. 95 percentile: 0.3051s

Threads fairness:

events (avg/stddev): 19.5312/3.36

execution time (avg/stddev): 2.4941/0.02
3
、磁碟IO效能測試
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw prepare
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw run
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw cleanup
上述引數指定了最大建立16個執行緒,建立的文件總大小為3G,文件讀寫模式為隨機讀。

CD到空間足夠的檔案系統,執行命令等待建立

test1:/root>#sysbench --test=fileio --num-threads=64 --file-total-size=12G --file-test-mode=rndrw prepare

sysbench v0.4.8: multi-threaded system evaluation benchmark

128 files, 98304Kb each, 12288Mb total

Creating files for the test...

test1: /root>#sysbench --test=fileio --num-threads=64 --file-total-size=12G --file-test-mode=rndrw run

sysbench v0.4.8: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 64

Extra file open flags: 0

128 files, 96Mb each

12Gb total file size

Block size 16Kb

Number of random requests for random IO: 10000

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

Threads started!

Done.

Operations performed: 5991 Read, 4009 Write, 12424 Other = 22424 Total

Read 93.609Mb Written 62.641Mb Total transferred 156.25Mb (64.986Mb/sec)

4159.07 Requests/sec executed

Test execution summary:

total time: 2.4044s

total number of events: 10000

total time taken by event execution: 23.6357

per-request statistics:

min: 0.0000s

avg: 0.0024s

max: 0.3453s

approx. 95 percentile: 0.0161s

Threads fairness:

events (avg/stddev): 156.2500/48.33

execution time (avg/stddev): 0.3693/0.15

test2: sysbench --test=fileio --num-threads=64 --file-total-size=12G --file-test-mode=rndrw run

sysbench v0.4.8: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 64

Extra file open flags: 0

128 files, 96Mb each

12Gb total file size

Block size 16Kb

Number of random requests for random IO: 10000

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

Threads started!

Done.

Operations performed: 5996 Read, 4011 Write, 11032 Other = 21039 Total

Read 93.688Mb Written 62.672Mb Total transferred 156.36Mb (19.025Mb/sec)

1217.61 Requests/sec executed

Test execution summary:

total time: 8.2186s

total number of events: 10007

total time taken by event execution: 82.9911

per-request statistics:

min: 0.0000s

avg: 0.0083s

max: 0.7963s

approx. 95 percentile: 0.0140s

Threads fairness:

events (avg/stddev): 156.3594/39.62

execution time (avg/stddev): 1.2967/0.50

我們看到兩臺機器的速度差好多,一個64M/S,一個19M/S.第二臺估計有問題,需要找找原因。測試完後記得刪除資料,否則會佔用空間。

sysbench --test=fileio --num-threads=64 --file-total-size=12G --file-test-mode=rndrw cleanup

4、記憶體測試

sysbench --test=memory --memory-block-size=8192 --memory-total-size=4G run上述引數指定了本次測試整個過程是在記憶體中傳輸 4G 的資料量,每個 block 大小為 8K

test1:/root>#sysbench --test=memory --num-threads=32 --memory-block-size=8192 --memory-total-size=512G run

sysbench v0.4.8: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 32

Doing memory operations speed test

Memory block size: 8K

Memory transfer size: 524288M

Memory operations type: write

Memory scope type: global

Threads started!

WARNING: Operation time (0.000000) is less than minimal counted value, counting as 1.000000

WARNING: Percentile statistics will be inaccurate

Done.

Operations performed: 67108864 (404978.13 ops/sec)

524288.00 MB transferred (3163.89 MB/sec)

Test execution summary:

total time: 165.7098s

total number of events: 67108864

total time taken by event execution: 2255.6291

per-request statistics:

min: 0.0000s

avg: 0.0000s

max: 1.3688s

approx. 95 percentile: 0.0000s

Threads fairness:

events (avg/stddev): 2097152.0000/48708.11

execution time (avg/stddev): 70.4884/1.38

test2:

Test execution summary:

total time: 168.1723s

total number of events: 67108864

total time taken by event execution: 2317.9228

per-request statistics:

min: 0.0000s

avg: 0.0000s

max: 1.5573s

approx. 95 percentile: 0.0000s

Threads fairness:

events (avg/stddev): 2097152.0000/41302.17

execution time (avg/stddev): 72.4351/1.29

以下不是我測試的,為完整性,從下面網址拷過來的。

http://hi.baidu.com/tister/blog/item/1b0cc4f945d5005d242df263.html

5OLTP測試

1 、準備資料
# sysbench --debug=off --test=oltp --mysql-host=10.15.2.137 --mysql-user=test --mysql-password=test --oltp-table-size=1000000 --mysql-db=test --oltp-table-name=stest --num-threads=20 --max-requests=10000 --oltp-auto-inc=off --mysql-engine-trx=yes prepare

2
、測試
# sysbench --debug=off --test=oltp --mysql-host=10.15.2.137 --mysql-user=test --mysql-password=test --oltp-table-size=1000000 --mysql-db=test --oltp-table-name=stest --num-threads=20 --max-requests=10000 --oltp-auto-inc=off --mysql-engine-trx=yes run

3
、刪除資料
# sysbench --debug=off --test=oltp --mysql-host=10.15.2.137 --mysql-user=test --mysql-password=test --oltp-table-size=1000000 --mysql-db=test --oltp-table-name=stest --num-threads=20 --max-requests=10000 --oltp-auto-inc=off --mysql-engine-trx=yes cleanup

指定了表最大記錄數為 1000000,其他引數就很好理解了,主要是指定登入方式。測試 OLTP 時,能夠自己先建立資料庫 sbtest,或自己用引數 --mysql-db 來指定其他資料庫。--mysql-table-engine 還能夠指定為 innodb MySQL 支援的表儲存引擎型別。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/668365/viewspace-1014757/,如需轉載,請註明出處,否則將追究法律責任。

相關文章