Linux 性能测试工具 sysbench 的安装与简单使用
文章目录
Linux 性能测试工具 sysbench 的安装与简单使用
一 背景
二 实验环境
2.1 操作系统
2.2 其他配置
三 安装
四 简单使用过程
4.1 查看软件版本
4.2 查看系统帮助
4.3 测试过程
4.4 CPU 性能测试
4.4.1 查看帮助信息
4.4.2 测试过程
4.5 内存测试
4.5.1 查看帮助信息
4.5.2 测试过程
4.6 磁盘I/O测试
4.6.1 查看帮助信息
4.6.2 测试过程
4.7 线程测试
4.7.1 帮助信息
4.7.2 测试过程
4.8 Mutex 测试
4.8.1 帮助信息
4.8.2 测试过程
五 总结
六 参考资料
Linux 性能测试工具 sysbench 的安装与简单使用
一 背景
sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。
sysbench 支持以下几种测试模式 :
1、CPU运算性能
2、内存分配及传输速度
3、磁盘IO性能
4、POSIX线程性能
5、互斥性测试
6、数据库性能(OLTP基准测试)。目前sysbench主要支持 MySQL,PostgreSQL 等几种数据库。
二 实验环境
2.1 操作系统
[gysl@gysl-DevOps ~]$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)
2.2 其他配置
安装EPEL,安装方法之前的文章有介绍。
三 安装
安装命令如下:
[gysl@gysl-DevOps ~]$ sudo yum -y install sysbench
四 简单使用过程
4.1 查看软件版本
[gysl@gysl-DevOps ~]$ sysbench --version
sysbench 1.0.9
4.2 查看系统帮助
[gysl@gysl-DevOps ~]$ sysbench --help
See 'sysbench --test=<name> help' for a list of options for each test. #查看每个测试项目的更多选项列表
Usage:
sysbench [options]... [testname] [command]
Commands implemented by most tests: prepare run cleanup help
General options:
--threads=N number of threads to use [1] #创建测试线程的数目。默认为1。
--events=N limit for total number of events [0]
--time=N limit for total execution time in seconds [10]
--forced-shutdown=STRING number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off] #超过max-time强制中断。默认是off。
--thread-stack-size=SIZE size of stack per thread [64K] #每个线程的堆栈大小。默认是32K。
--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
--tx-rate=N deprecated alias for --rate [0]
--max-requests=N deprecated alias for --events [0] #请求的最大数目。默认为10000,0代表不限制。
--max-time=N deprecated alias for --time [0] #最大执行时间,单位是s。默认是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
pgsql - PostgreSQL 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]
pgsql options:
--pgsql-host=STRING PostgreSQL server host [localhost]
--pgsql-port=N PostgreSQL server port [5432]
--pgsql-user=STRING PostgreSQL user [sbtest]
--pgsql-password=STRING PostgreSQL password []
--pgsql-db=STRING PostgreSQL database name [sbtest]
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.
4.3 测试过程
sysbench 的测试过程一般分为三个阶段:
prepare:准备阶段,准备测试数据。
run:执行测试阶段。
cleanup:清理垃圾数据阶段。
4.4 CPU 性能测试
找出指定范围内最大质数,时间越短 CPU 性能越好。
4.4.1 查看帮助信息
[gysl@gysl-DevOps ~]$ sysbench --test=cpu help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
cpu options:
--cpu-max-prime=N upper limit for primes generator [10000]
4.4.2 测试过程
[gysl@gysl-DevOps ~]$ sudo sysbench --test=cpu --cpu-max-prime=5000 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Prime numbers limit: 5000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 3059.82
General statistics:
total time: 10.0002s
total number of events: 30603
Latency (ms):
min: 0.29
avg: 0.33
max: 6.10
95th percentile: 0.50
sum: 9979.54
Threads fairness:
events (avg/stddev): 30603.0000/0.00
execution time (avg/stddev): 9.9795/0.00
本次测试中,线程数为1,质数个数为5000。
4.5 内存测试
4.5.1 查看帮助信息
[gysl@gysl-DevOps ~]$ sysbench --test=memory help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
memory options:
--memory-block-size=SIZE size of memory block for test [1K]
--memory-total-size=SIZE total size of data to transfer [100G]
--memory-scope=STRING memory access scope {global,local} [global]
--memory-hugetlb[=on|off] allocate memory from HugeTLB pool [off]
--memory-oper=STRING type of memory operations {read, write, none} [write]
--memory-access-mode=STRING memory access mode {seq,rnd} [seq]
4.5.2 测试过程
[gysl@gysl-DevOps ~]$ free -h
total used free shared buff/cache available
Mem: 972M 137M 313M 7.6M 521M 637M
Swap: 0B 0B 0B
[gysl@gysl-DevOps ~]$ sudo sysbench --test=memory --memory-block-size=8k --memory-total-size=972M run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Running memory speed test with the following options:
block size: 8KiB
total size: 972MiB
operation: write
scope: global
Initializing worker threads...
Threads started!
Total operations: 124416 (1603394.35 per second)
972.00 MiB transferred (12526.52 MiB/sec)
General statistics:
total time: 0.0761s
total number of events: 124416
Latency (ms):
min: 0.00
avg: 0.00
max: 0.93
95th percentile: 0.00
sum: 61.24
Threads fairness:
events (avg/stddev): 124416.0000/0.00
execution time (avg/stddev): 0.0612/0.00
4.6 磁盘I/O测试
4.6.1 查看帮助信息
[gysl@gysl-DevOps ~]$ sysbench --test=fileio help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
fileio options:
--file-num=N number of files to create [128]
--file-block-size=N block size to use in all IO operations [16384]
--file-total-size=SIZE total size of files to create [2G]
--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
--file-io-mode=STRING file operations mode {sync,async,mmap} [sync]
--file-async-backlog=N number of asynchronous operatons to queue per thread [128]
--file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} []
--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
--file-fsync-all[=on|off] do fsync() after each write operation [off]
--file-fsync-end[=on|off] do fsync() at the end of test [on]
--file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
--file-rw-ratio=N reads/writes ratio for combined test [1.5]
4.6.2 测试过程
[gysl@gysl-DevOps ~]$ sysbench --test=fileio help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
fileio options:
--file-num=N number of files to create [128]
--file-block-size=N block size to use in all IO operations [16384]
--file-total-size=SIZE total size of files to create [2G]
--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
--file-io-mode=STRING file operations mode {sync,async,mmap} [sync]
--file-async-backlog=N number of asynchronous operatons to queue per thread [128]
--file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} []
--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
--file-fsync-all[=on|off] do fsync() after each write operation [off]
--file-fsync-end[=on|off] do fsync() at the end of test [on]
--file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
--file-rw-ratio=N reads/writes ratio for combined test [1.5]
[gysl@gysl-DevOps ~]$ sudo sysbench --test=fileio --num-threads=1 --file-total-size=1G --file-test-mode=rndrw prepare
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
128 files, 8192Kb each, 1024Mb total
Creating files for the test...
Extra file open flags: 0
Creating file test_file.0
Creating file test_file.1
.......................
[gysl@gysl-DevOps ~]$ sudo sysbench --test=fileio --num-threads=1 --file-total-size=1G --file-test-mode=rndrw run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Extra file open flags: 0
128 files, 8MiB each
1GiB total file size
Block size 16KiB
Number of IO requests: 0
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
Initializing worker threads...
Threads started!
File operations:
reads/s: 2042.32
writes/s: 1361.55
fsyncs/s: 4351.23
Throughput:
read, MiB/s: 31.91
written, MiB/s: 21.27
General statistics:
total time: 10.0190s
total number of events: 78021
Latency (ms):
min: 0.00
avg: 0.13
max: 105.19
95th percentile: 0.16
sum: 9932.94
Threads fairness:
events (avg/stddev): 78021.0000/0.00
execution time (avg/stddev): 9.9329/0.00
[gysl@gysl-DevOps ~]$ sudo sysbench --test=fileio --num-threads=1 --file-total-size=1G --file-test-mode=rndrw cleanup
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Removing test files...
4.7 线程测试
4.7.1 帮助信息
[gysl@gysl-DevOps ~]$ sysbench --test=threads help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
threads options:
--thread-yields=N number of yields to do per request [1000]
--thread-locks=N number of locks per thread [8]
4.7.2 测试过程
[gysl@gysl-DevOps ~]$ sudo sysbench --test=threads --num-threads=500 --thread-yields=100 --thread-locks=4 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 500
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 10.5847s
total number of events: 50140
Latency (ms):
min: 0.15
avg: 104.54
max: 1874.74
95th percentile: 427.07
sum: 5241634.75
Threads fairness:
events (avg/stddev): 100.2800/25.55
execution time (avg/stddev): 10.4833/0.07
4.8 Mutex 测试
4.8.1 帮助信息
[gysl@gysl-DevOps ~]$ sudo sysbench --test=mutex help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
mutex options:
--mutex-num=N total size of mutex array [4096]
--mutex-locks=N number of mutex locks to do per thread [50000]
--mutex-loops=N number of empty loops to do outside mutex lock [10000]
4.8.2 测试过程
[gysl@gysl-DevOps ~]$ sudo sysbench --test=mutex --mutex-num=2048 --mutex-locks=20000 --mutex-loops=5000 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 0.0342s
total number of events: 1
Latency (ms):
min: 33.58
avg: 33.58
max: 33.58
95th percentile: 33.72
sum: 33.58
Threads fairness:
events (avg/stddev): 1.0000/0.00
execution time (avg/stddev): 0.0336/0.00
五 总结
5.1 对于数据库的测试,本文未进行介绍,后续遇到该情况时会进行介绍。
5.2 由于时间仓促,文章中大部分英文本人并未进行翻译,但是涉及到的英文都不算难。
5.3 磁盘I/O测试中,–file-extra-flags 选项比较重要,有的存储设备是直接I/O,其他详情还请查阅相关资料。
5.4 本文仅仅根据帮助信息整理完成,其他详情还请参考官方手册。
六 参考资料
6.1 相关资料
6.2 相关手册
6.3 IO测试参考
---------------------
作者:MRIVANDU
来源:CSDN
原文:https://blog.csdn.net/solaraceboy/article/details/88631489
版权声明:本文为博主原创文章,转载请附上博文链接!
文章目录
Linux 性能测试工具 sysbench 的安装与简单使用
一 背景
二 实验环境
2.1 操作系统
2.2 其他配置
三 安装
四 简单使用过程
4.1 查看软件版本
4.2 查看系统帮助
4.3 测试过程
4.4 CPU 性能测试
4.4.1 查看帮助信息
4.4.2 测试过程
4.5 内存测试
4.5.1 查看帮助信息
4.5.2 测试过程
4.6 磁盘I/O测试
4.6.1 查看帮助信息
4.6.2 测试过程
4.7 线程测试
4.7.1 帮助信息
4.7.2 测试过程
4.8 Mutex 测试
4.8.1 帮助信息
4.8.2 测试过程
五 总结
六 参考资料
Linux 性能测试工具 sysbench 的安装与简单使用
一 背景
sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。
sysbench 支持以下几种测试模式 :
1、CPU运算性能
2、内存分配及传输速度
3、磁盘IO性能
4、POSIX线程性能
5、互斥性测试
6、数据库性能(OLTP基准测试)。目前sysbench主要支持 MySQL,PostgreSQL 等几种数据库。
二 实验环境
2.1 操作系统
[gysl@gysl-DevOps ~]$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)
1
2
2.2 其他配置
安装EPEL,安装方法之前的文章有介绍。
三 安装
安装命令如下:
[gysl@gysl-DevOps ~]$ sudo yum -y install sysbench
1
四 简单使用过程
4.1 查看软件版本
[gysl@gysl-DevOps ~]$ sysbench --version
sysbench 1.0.9
1
2
4.2 查看系统帮助
[gysl@gysl-DevOps ~]$ sysbench --help
See 'sysbench --test=<name> help' for a list of options for each test. #查看每个测试项目的更多选项列表
Usage:
sysbench [options]... [testname] [command]
Commands implemented by most tests: prepare run cleanup help
General options:
--threads=N number of threads to use [1] #创建测试线程的数目。默认为1。
--events=N limit for total number of events [0]
--time=N limit for total execution time in seconds [10]
--forced-shutdown=STRING number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off] #超过max-time强制中断。默认是off。
--thread-stack-size=SIZE size of stack per thread [64K] #每个线程的堆栈大小。默认是32K。
--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
--tx-rate=N deprecated alias for --rate [0]
--max-requests=N deprecated alias for --events [0] #请求的最大数目。默认为10000,0代表不限制。
--max-time=N deprecated alias for --time [0] #最大执行时间,单位是s。默认是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
pgsql - PostgreSQL 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]
pgsql options:
--pgsql-host=STRING PostgreSQL server host [localhost]
--pgsql-port=N PostgreSQL server port [5432]
--pgsql-user=STRING PostgreSQL user [sbtest]
--pgsql-password=STRING PostgreSQL password []
--pgsql-db=STRING PostgreSQL database name [sbtest]
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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
4.3 测试过程
sysbench 的测试过程一般分为三个阶段:
prepare:准备阶段,准备测试数据。
run:执行测试阶段。
cleanup:清理垃圾数据阶段。
4.4 CPU 性能测试
找出指定范围内最大质数,时间越短 CPU 性能越好。
4.4.1 查看帮助信息
[gysl@gysl-DevOps ~]$ sysbench --test=cpu help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
cpu options:
--cpu-max-prime=N upper limit for primes generator [10000]
1
2
3
4
5
6
4.4.2 测试过程
[gysl@gysl-DevOps ~]$ sudo sysbench --test=cpu --cpu-max-prime=5000 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Prime numbers limit: 5000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 3059.82
General statistics:
total time: 10.0002s
total number of events: 30603
Latency (ms):
min: 0.29
avg: 0.33
max: 6.10
95th percentile: 0.50
sum: 9979.54
Threads fairness:
events (avg/stddev): 30603.0000/0.00
execution time (avg/stddev): 9.9795/0.00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
本次测试中,线程数为1,质数个数为5000。
4.5 内存测试
4.5.1 查看帮助信息
[gysl@gysl-DevOps ~]$ sysbench --test=memory help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
memory options:
--memory-block-size=SIZE size of memory block for test [1K]
--memory-total-size=SIZE total size of data to transfer [100G]
--memory-scope=STRING memory access scope {global,local} [global]
--memory-hugetlb[=on|off] allocate memory from HugeTLB pool [off]
--memory-oper=STRING type of memory operations {read, write, none} [write]
--memory-access-mode=STRING memory access mode {seq,rnd} [seq]
1
2
3
4
5
6
7
8
9
10
11
4.5.2 测试过程
[gysl@gysl-DevOps ~]$ free -h
total used free shared buff/cache available
Mem: 972M 137M 313M 7.6M 521M 637M
Swap: 0B 0B 0B
[gysl@gysl-DevOps ~]$ sudo sysbench --test=memory --memory-block-size=8k --memory-total-size=972M run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Running memory speed test with the following options:
block size: 8KiB
total size: 972MiB
operation: write
scope: global
Initializing worker threads...
Threads started!
Total operations: 124416 (1603394.35 per second)
972.00 MiB transferred (12526.52 MiB/sec)
General statistics:
total time: 0.0761s
total number of events: 124416
Latency (ms):
min: 0.00
avg: 0.00
max: 0.93
95th percentile: 0.00
sum: 61.24
Threads fairness:
events (avg/stddev): 124416.0000/0.00
execution time (avg/stddev): 0.0612/0.00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
4.6 磁盘I/O测试
4.6.1 查看帮助信息
[gysl@gysl-DevOps ~]$ sysbench --test=fileio help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
fileio options:
--file-num=N number of files to create [128]
--file-block-size=N block size to use in all IO operations [16384]
--file-total-size=SIZE total size of files to create [2G]
--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
--file-io-mode=STRING file operations mode {sync,async,mmap} [sync]
--file-async-backlog=N number of asynchronous operatons to queue per thread [128]
--file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} []
--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
--file-fsync-all[=on|off] do fsync() after each write operation [off]
--file-fsync-end[=on|off] do fsync() at the end of test [on]
--file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
--file-rw-ratio=N reads/writes ratio for combined test [1.5]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
4.6.2 测试过程
[gysl@gysl-DevOps ~]$ sysbench --test=fileio help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
fileio options:
--file-num=N number of files to create [128]
--file-block-size=N block size to use in all IO operations [16384]
--file-total-size=SIZE total size of files to create [2G]
--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
--file-io-mode=STRING file operations mode {sync,async,mmap} [sync]
--file-async-backlog=N number of asynchronous operatons to queue per thread [128]
--file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} []
--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
--file-fsync-all[=on|off] do fsync() after each write operation [off]
--file-fsync-end[=on|off] do fsync() at the end of test [on]
--file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
--file-rw-ratio=N reads/writes ratio for combined test [1.5]
[gysl@gysl-DevOps ~]$ sudo sysbench --test=fileio --num-threads=1 --file-total-size=1G --file-test-mode=rndrw prepare
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
128 files, 8192Kb each, 1024Mb total
Creating files for the test...
Extra file open flags: 0
Creating file test_file.0
Creating file test_file.1
.......................
[gysl@gysl-DevOps ~]$ sudo sysbench --test=fileio --num-threads=1 --file-total-size=1G --file-test-mode=rndrw run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Extra file open flags: 0
128 files, 8MiB each
1GiB total file size
Block size 16KiB
Number of IO requests: 0
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
Initializing worker threads...
Threads started!
File operations:
reads/s: 2042.32
writes/s: 1361.55
fsyncs/s: 4351.23
Throughput:
read, MiB/s: 31.91
written, MiB/s: 21.27
General statistics:
total time: 10.0190s
total number of events: 78021
Latency (ms):
min: 0.00
avg: 0.13
max: 105.19
95th percentile: 0.16
sum: 9932.94
Threads fairness:
events (avg/stddev): 78021.0000/0.00
execution time (avg/stddev): 9.9329/0.00
[gysl@gysl-DevOps ~]$ sudo sysbench --test=fileio --num-threads=1 --file-total-size=1G --file-test-mode=rndrw cleanup
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Removing test files...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
4.7 线程测试
4.7.1 帮助信息
[gysl@gysl-DevOps ~]$ sysbench --test=threads help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
threads options:
--thread-yields=N number of yields to do per request [1000]
--thread-locks=N number of locks per thread [8]
1
2
3
4
5
6
7
4.7.2 测试过程
[gysl@gysl-DevOps ~]$ sudo sysbench --test=threads --num-threads=500 --thread-yields=100 --thread-locks=4 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 500
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 10.5847s
total number of events: 50140
Latency (ms):
min: 0.15
avg: 104.54
max: 1874.74
95th percentile: 427.07
sum: 5241634.75
Threads fairness:
events (avg/stddev): 100.2800/25.55
execution time (avg/stddev): 10.4833/0.07
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
4.8 Mutex 测试
4.8.1 帮助信息
[gysl@gysl-DevOps ~]$ sudo sysbench --test=mutex help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
mutex options:
--mutex-num=N total size of mutex array [4096]
--mutex-locks=N number of mutex locks to do per thread [50000]
--mutex-loops=N number of empty loops to do outside mutex lock [10000]
1
2
3
4
5
6
7
8
4.8.2 测试过程
[gysl@gysl-DevOps ~]$ sudo sysbench --test=mutex --mutex-num=2048 --mutex-locks=20000 --mutex-loops=5000 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.9 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 0.0342s
total number of events: 1
Latency (ms):
min: 33.58
avg: 33.58
max: 33.58
95th percentile: 33.72
sum: 33.58
Threads fairness:
events (avg/stddev): 1.0000/0.00
execution time (avg/stddev): 0.0336/0.00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
五 总结
5.1 对于数据库的测试,本文未进行介绍,后续遇到该情况时会进行介绍。
5.2 由于时间仓促,文章中大部分英文本人并未进行翻译,但是涉及到的英文都不算难。
5.3 磁盘I/O测试中,–file-extra-flags 选项比较重要,有的存储设备是直接I/O,其他详情还请查阅相关资料。
5.4 本文仅仅根据帮助信息整理完成,其他详情还请参考官方手册。
六 参考资料
6.1 相关资料 https://www.howtoforge.com/how-to-benchmark-your-system-cpu-file-io-mysql-with-sysbench
6.2 相关手册 https://github.com/mrivandu/E-books/blob/master/SomeManuals/sysbench-manual.pdf
6.3 IO测试参考 https://wiki.gentoo.org/wiki/Sysbench#Using_the_fileio_workload
---------------------
作者:MRIVANDU
来源:CSDN
原文:https://blog.csdn.net/solaraceboy/article/details/88631489
版权声明:本文为博主原创文章,转载请附上博文链接!
Linux 性能测试工具 sysbench 的安装与简单使用的更多相关文章
- MySQL性能测试工具sysbench的安装和使用
sysbench是一个开源的.模块化的.跨平台的多线程性能测试工具,可以用来进行CPU.内存.磁盘I/O.线程.数据库的性能测试.目前支持的数据库有MySQL.Oracle和PostgreSQL.当前 ...
- [转发]Linux性能测试工具之Lmbench特性、安装及使用
Linux性能测试工具之Lmbench特性.安装及使用2015年07月16日 10:13:48 Michaelwubo 阅读数:2466Linux性能测试工具Lmbench 是一套简易可移植的,符合A ...
- Linux 性能测试工具Lmbench详解
Linux 性能测试工具Lmbench详解 2010-06-04 16:07 佚名 评测中心 字号:T | T Lmbench 是一套简易可移植的,符合ANSI/C 标准为UNIX/POSIX 而制定 ...
- Linux性能测试工具
Linux性能测试工具 在测试中,我们不仅需要查看系统日志信息,而且还要使用大量的性能监测工具来关注某些地方,如内存.CPU等.在Linux系统中,所有的运行参数保存在虚拟目录/proc中,换句话说, ...
- Linux性能测试工具安装全集
stress 下载地址:http://people.seas.harvard.edu/~apw/stress/ 一.stress工具安装:1.获取stress源码安装包(stress-1.0.4.ta ...
- Mysql多线程性能测试工具sysbench 安装、使用和测试
From:http://www.cnblogs.com/zhoujinyi/archive/2013/04/19/3029134.html 摘要: sysbench是一个开源的.模块化的.跨 ...
- Linux 网络性能测试工具 iperf 的安装和使用
简介:Iperf是一个网络性能测试工具.可以测试TCP和UDP带宽质量,可以测量最大TCP带宽,具有多种参数和UDP特性,可以报告带宽,延迟抖动和数据包丢失.Iperf在Linux和windows平台 ...
- 安装性能测试工具:sysbench和使用apache的ab
一.软件的用途,它主要包括以下几种方式的测试:1.cpu性能2.磁盘io性能3.调度程序性能4.内存分配及传输速度5.POSIX线程性能6.数据库性能(OLTP基准测试) 这个软件为什么找不到官网呢? ...
- 开源多线程性能测试工具-sysbench
导读 sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试.数据库目前支持MySQL/Oracle/PostgreSQL.本文主要演示Mysql测试 ...
随机推荐
- 《SQL Server 2012 T-SQL基础》读书笔记 - 3.联接查询
Chapter 3 Joins Cross Joins(交叉联接)就是返回两个表的笛卡尔积(m行的表cross join一个n行的表得到一个m * n行的结果),它有两种标准SQL语法,第一种: SE ...
- react-native 组件之间传值
1.通过 AsyncStorage 将值保存在本地(最低端的方法) import { AsyncStorage, } from 'react-native'; // 保存 IP AsyncStorag ...
- 爬虫解析库xpath
# xpath简介 XPath即为XML路径语言(XML Path Language),它是一种用来确定XML文档中某部分位置的语言.用于在 XML 文档中通过元素和属性进行导航. XPath基于XM ...
- 多线程threading初识,线程等待
1.线程是程序里面最小的执行单元. 2.进程是资源的集合. 线程是包含在进程里面的,一个进程可以有多个线程,但只要要有一个线程. 一.多线程,就是N个线程一起干活: 1.传统方式,串行,循环5次需要1 ...
- c# thread4——lock,死锁,以及monitor关键字
多线程的存在是提高系统效率,挖掘cpu性能的一种手段,那么控制它,能够协同多个线程不发生bug是关键. 首先我们来看一段不安全的多线程代码. public abstract class Calcula ...
- django中orm多表查询,减少数据库查询操作
.select_related() 的使用
- Reverse Linked List(反转单向链表)
来源:https://leetcode.com/problems/reverse-linked-list Reverse a singly linked list. 递归方法:递归调用直到最后一个节点 ...
- linux文件io与标准io
文件IO实际是API,Linux对文件操作主要流程为:打开(open),操作(write.read.lseek),关闭(close). 1.打开文件函数open(): 涉及的头文件: #includ ...
- squid代理服务问答
1. 简述一下squid的用途?squid可以做代理和缓存服务器,而做代理时,可以分为正向代理和反向代理.正向代理用在企业办公环境中,企业员工上网通过代理来上网,代理的缓存功能可以为企业节省宝贵的带宽 ...
- 《剑指offer》面试题14 调整数组顺序使奇数位于偶数前面 Java版
(输入整数数组,使所有奇数位于前半部分,所有偶数位于后半部分.) 我的方法:想到用两个下标分别表示奇数和偶数的界线,一个在开头,一个在末尾,判断每一个数字的类别,然后将它放入对应的范围内,移动下标,直 ...