【性能测试工具sysbench】

sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。

数据库目前支持MySQL/Oracle/PostgreSQL。本文只是简单演示一下几种测试的用法,后续准备利用sysbench来对MySQL进行一系列的测试。具体的一些参数设置,需要根据不同的测试要求来进行调整。

sysbench是一个开源的、模块化的、跨平台的多线程性能测试工具,可以用来进行CPU、内存、磁盘I/O、线程、数据库的性能测试。目前支持的数据库有MySQL、Oracle和PostgreSQL。当前功能允许测试的系统参数有:

file I/O performance (文件I / O性能)

scheduler performance (调度性能)

memory allocation and transfer speed (内存分配和传输速度)

POSIX threads implementation performance (POSIX线程执行绩效)

database server performance (OLTP benchmark) (数据库服务器性能)

sysbench支持以下几种测试模式:

1、CPU运算性能

2、磁盘IO性能

3、调度程序性能

4、内存分配及传输速度

5、POSIX线程性能

6、数据库性能(OLTP基准测试)

目前sysbench主要支持 mysql,drizzle,pgsql,oracle 等几种数据库。

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 #指定测试项目名称。

  --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 #版本信息。

Usage:

  sysbench [options]... [testname] [command]

Commands implemented by most tests: prepare run cleanup help

General options:

  --threads=N                     number of threads to use [1]

  --events=N                      limit for total number of events [0]

  --time=N                        limit for total execution time in seconds [10]

  --warmup-time=N                 execute events for this many seconds with statistics disabled before the actual benchmark run with statistics enabled [0]

  --forced-shutdown=STRING        number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off]

  --thread-stack-size=SIZE        size of stack per thread [64K]

  --thread-init-timeout=N         wait time in seconds for worker threads to initialize [30]

  --rate=N                        average transactions rate. 0 for unlimited rate [0]

  --report-interval=N             periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]

  --report-checkpoints=[LIST,...] dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. []

  --debug[=on|off]                print more debugging info [off]

  --validate[=on|off]             perform validation checks where possible [off]

  --help[=on|off]                 print help and exit [off]

  --version[=on|off]              print version and exit [off]

  --config-file=FILENAME          File containing command line options

  --luajit-cmd=STRING             perform LuaJIT control command. This option is equivalent to 'luajit -j'. See LuaJIT documentation for more information

  --tx-rate=N                     deprecated alias for --rate [0]

  --max-requests=N                deprecated alias for --events [0]

  --max-time=N                    deprecated alias for --time [0]

  --num-threads=N                 deprecated alias for --threads [1]

Pseudo-Random Numbers Generator options:

  --rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]

  --rand-spec-iter=N number of iterations used for numbers generation [12]

  --rand-spec-pct=N  percentage of values to be treated as 'special' (for special distribution) [1]

  --rand-spec-res=N  percentage of 'special' values to use (for special distribution) [75]

  --rand-seed=N      seed for random number generator. When 0, the current time is used as a RNG seed. [0]

  --rand-pareto-h=N  parameter h for pareto distribution [0.2]

Log options:

  --verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3]

  --percentile=N       percentile to calculate in latency statistics (1-100). Use the special value of 0 to disable percentile calculations [95]

  --histogram[=on|off] print latency histogram in report [off]

General database options:

  --db-driver=STRING  specifies database driver to use ('help' to get list of available drivers)

  --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]

  --db-debug[=on|off] print database-specific debug information [off]

Compiled-in database drivers:

  mysql - MySQL driver

mysql options:

  --mysql-host=[LIST,...]          MySQL server host [localhost]

  --mysql-port=[LIST,...]          MySQL server port [3306]

  --mysql-socket=[LIST,...]        MySQL socket

  --mysql-user=STRING              MySQL user [sbtest]

  --mysql-password=STRING          MySQL password []

  --mysql-db=STRING                MySQL database name [sbtest]

  --mysql-ssl[=on|off]             use SSL connections, if available in the client library [off]

  --mysql-ssl-cipher=STRING        use specific cipher for SSL connections []

  --mysql-compression[=on|off]     use compression, if available in the client library [off]

  --mysql-debug[=on|off]           trace all client library calls [off]

  --mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205]

  --mysql-dry-run[=on|off]         Dry run, pretend that all MySQL client API calls are successful without executing them [off]

Compiled-in tests:

  fileio - File I/O test

  cpu - CPU performance test

  memory - Memory functions speed test

  threads - Threads subsystem performance test

  mutex - Mutex performance test

See 'sysbench <testname> help' for a list of options for each test.

猜你喜欢

转载自gaojingsong.iteye.com/blog/2381956