sysbench测试mysql性能

[source lang=”python”]

#!/usr/bin/env python
import string
import os

host = ‘127.0.0.1’
port = ‘3306’
user = ‘root’
pwd = ‘passwd’
db = ‘my_db’

max_request = ‘80000’
num_threads_array = [1,4,8,16,32,64,128,256]

#–oltp-test-mode=nontrx –oltp-skip-trx=yes
cmd_base = ‘sysbench –test=oltp –oltp-test-mode=nontrx –oltp-table-size=1000000 –mysql-host=%s –mysql-port=%s –mysql-user=%s –mysql-password=%s –mysql-db=%s –max-requests=%s –db-driver=mysql –oltp-nontrx-mode=insert –db-ps-mode=auto’%(host, port, user, pwd,db, max_request)

for num_thread in num_threads_array:
thread_option = ‘ –num-threads=%d’%(num_thread)

cmd_prepare = cmd_base + thread_option + ‘ prepare’
cmd_run = cmd_base + thread_option + ‘ run’
cmd_cleanup = cmd_base + thread_option + ‘ cleanup’

os.system(cmd_cleanup)

print(cmd_prepare)
os.system(cmd_prepare)

print(cmd_run)
os.system(cmd_run)

print(cmd_cleanup)
os.system(cmd_cleanup)

[/source]

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注