抑郁症健康,内容丰富有趣,生活中的好帮手!
抑郁症健康 > Linux服务器常见运维性能测试(3)CPU测试super_pi sysbench

Linux服务器常见运维性能测试(3)CPU测试super_pi sysbench

时间:2021-09-01 04:49:06

相关推荐

Linux服务器常见运维性能测试(3)CPU测试

常见性能测试软件CPU测试:super_pi (计算圆周率)CPU测试:sysbench(CPU功能测试部分)下载安装sysbench综合测试功能执行CPU测试

最近需要测试一批服务器的相关硬件性能,以及在常规环境下的硬件运行稳定情况,需要持续拷机测试稳定性。所以找了一些测试用例。本次测试包括在服务器的高低温下性能记录及压力测试,高低电压下性能记录及压力测试,常规环境下CPU满载稳定运行的功率记录。

这个系列是根据这次测试项目的相关测试总结,关于各种常见性能测试及拷机软件的整理。

本章为系列3,主要介绍

系列往期:

Linux服务器常见运维性能测试(1)综合跑分unixbench、superbench

Linux服务器常见运维性能测试(2)内存测试mbw、stream

常见性能测试软件

综合测试:UnixBench(综合跑分),superbench(快速脚本)

内存测试:mbw(内存带宽测试),stream(读写响应测试)

CPU测试:super_pi(计算圆周率)、sysbench(CPU功能测试部分)

网络测试:netperf

IO测试:FIO、iometer

辅助监测:sensors、top、

CPU测试:super_pi (计算圆周率)

super_pi(π)一般用于进行压力测试,但同时也可以通过计算π所用时间评估CPU算力,参考CPU性能。其常用于硬件发烧友中对超频后的CPU进行压力测试,因其只用到基础的浮点运算,而不涉及其他的系统库环境,所以,很适合用于排查CPU物理问题。当系统出现不明原因的死机、缓慢、自动重启等故障,我们可用其协助分析是否CPU不稳定导致的。

官方下载地址:/

解压后直接运行即可

tar -jxvf super_pi.tar.bz2./super_pi 20 #20为测试计算到小数点后的位数

该程序在 SMP 环境中,只能让 CPU 满载运行,所以,对于多 CPU 的环境,可同时用多个程序并发运行。super_pi同样也可以用于拷机测试稳定性,在运行期间CPU满载运行,可以持续关注设备运行稳定性和温度情况。

补充说明※

1、命令运行中使用的参数m,是指位数,表示要算2的多少次方位,如通常要算小数点后1M位(2^20次方);

2、m最大到25次方,若设置再大的值,会自动缩小到该值

例子:

Specified M(=30) is too large. M is set to 25.Start of PI calculation up to 33554432 decimal digits

3、因算法不同,该程序不能用于和Windows平台上的Super PI进行性能对比(实际上,快很多)

CPU测试:sysbench(CPU功能测试部分)

sysbench是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况。其可以作为综合性能测试工具,它主要包括以下几种方式的测试:磁盘io性能、数据库性能、内存分配及传输速度等。

它主要包括以下几种方式的测试:

CPU运算性能

file I/O performance (磁盘IO性能)

scheduler performance (调度程序性能)

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

POSIX threads implementation performance (POSIX线程性能)

database server performance (OLTP benchmark) (数据库服务器性能,OLTP基准测试)

sysbench作为综合性能测试工具有很多可以测试使用的功能,我们这次测试主要用其测试CPU性能。

下载安装

下载地址:/akopytov/sysbench/archive/1.0.zip

解压安装:解压得到sysbench-1.0文件夹,进入文件夹执行安装程序

./autogen.sh如果报错:automake 1.10.x (aclocal) wasn't found, exiting 需要补充安装依赖包# 安装依赖包 yum install automake libtool -y./configure --without-mysql #由于我们使用sysbench只做CPU测试,不压mysql,所以放弃依赖mysqlmake #最后执行汇编安装make install #安装完毕

查看版本安装成功

sysbench综合测试功能

查看帮助文档

sysbench --helpUsage:sysbench [options]... [testname] [command]Commands implemented by most tests: prepare run cleanup helpGeneral options:--threads=N number of threads to use [1],创建测试线程的数目。默认为1.--events=N limit for total number of events [0],请求的最大数目,0代表不限制。--time=N limit for total execution time in seconds [10],最大执行时间,单位是s。默认是10s--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],每个线程的堆栈大小。默认是64K。--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],是否显示更多的调试信息。默认是off。--validate[=on|off] perform validation checks where possible [off],#在可能情况下执行验证检查。默认是off。--help[=on|off] print help and exit [off],#帮助信息--version[=on|off] print version and exit [off],#版本信息--config-file=FILENAMEFile containing command line options--tx-rate=N deprecated alias for --rate [0]--max-requests=Ndeprecated alias for --events [0]--max-time=Ndeprecated 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=Nseed 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],日志级别,默认为3,5=debug,0=只包含重要信息--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) [mysql]--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 driverpgsql - PostgreSQL drivermysql 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=STRINGMySQL password []--mysql-db=STRINGMySQL 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=STRINGPostgreSQL server host [localhost]--pgsql-port=NPostgreSQL server port [5432]--pgsql-user=STRINGPostgreSQL user [sbtest]--pgsql-password=STRING PostgreSQL password []--pgsql-db=STRING PostgreSQL database name [sbtest]Compiled-in tests:#测试项目fileio - File I/O testcpu - CPU performance testmemory - 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.

测试CPU的帮助文档

#sysbench --test=cpu help--cpu-max-prime=N 最大质数发生器数量。默认是10000

测试IO的帮助文档

# sysbench --test=fileio helpWARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.sysbench 1.0.17 (using system LuaJIT 2.0.4)fileio options:--file-num=N number of files to create [128],创建测试文件的数量。默认是128--file-block-size=N block size to use in all IO operations [16384],测试时文件块的大小。默认是16384(16K)--file-total-size=SIZE total size of files to create [2G],测试文件的总大小。默认是2G--file-test-mode=STRING 文件测试模式{seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)} --file-io-mode=STRING 文件操作模式{sync(同步),async(异步),fastmmap(快速map映射),slowmmap(慢map映射)}。默认是sync--file-async-backlog=N number of asynchronous operatons to queue per thread [128]--file-extra-flags=[LIST,...] 使用额外的标志来打开文件{sync,dsync,direct} 。默认为空--file-fsync-freq=N 执行fsync()的频率。(0 – 不使用fsync())。默认是100--file-fsync-all[=on|off]每执行完一次写操作就执行一次fsync。默认是off--file-fsync-end[=on|off]在测试结束时才执行fsync。默认是on--file-fsync-mode=STRING使用哪种方法进行同步{fsync, fdatasync}。默认是fsync--file-merged-requests=N如果可以,合并最多的IO请求数(0 – 表示不合并)。默认是0--file-rw-ratio=N 测试时的读写比例,默认时为1.5,即可3:2。

测试内存的帮助文档

# sysbench --test=memory helpWARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.sysbench 1.0.17 (using system LuaJIT 2.0.4)memory options:--memory-block-size=SIZE 测试时内存块大小。默认是1K--memory-total-size=SIZE 传输数据的总大小。默认是100G--memory-scope=STRING 内存访问范围{global,local}。默认是global--memory-hugetlb=[on|off] 从HugeTLB池内存分配。默认是off--memory-oper=STRING内存操作类型。{read, write, none} 默认是write--memory-access-mode=STRING存储器存取方式{seq,rnd} 默认是seq

测试线程的帮助文档

# sysbench threads helpsysbench 1.0.17 (using system LuaJIT 2.0.4)threads options:--thread-yields=N number of yields to do per request [1000],每个请求产生多少个线程。默认是1000--thread-locks=N number of locks per thread [8],每个线程的锁的数量。默认是8

sysben基本命令格式

sysbench [general-options]... --test=<test-name> [test-options]... commandGeneral 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 #指定测试类型。fileiocpumemorythreadsmutex--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 #版本信息。--report-interval --指定每多少秒在屏幕上输出一次结果--日志选项--verbosity=N --日志级别,默认为3,5=debug,0=只包含重要信息Compiled-in tests: #测试项目fileio - File I/O test #IOcpu - CPU performance test #CPUmemory - Memory functions speed test #内存threads - Threads subsystem performance test #线程mutex - Mutex performance test #互斥性能测试oltp - OLTP test # 数据库,事务处理

执行CPU测试

常用参数

–cpu-max-prime: 素数生成数量的上限

–threads: 线程数

–time: 运行时长,单位秒

–events: event上限次数

执行测试:

测试场景1:默认开启一个线程sysbench cpu --time=60 run

[root@localhost ~]# sysbench cpu --time=60 runsysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)Running the test with following options:Number of threads: 1Initializing random number generator from current timePrime numbers limit: 10000Initializing worker threads...Threads started!CPU speed:events per second: 836.83//CPU速度General statistics:total time:60.0004s //运行时间60stotal number of events: 50212//60s内共执行50212次eventLatency (ms):min:1.18 //最小耗时1.18msavg:1.19//平均耗时1.19msmax:2.76//最大耗时2.76ms95th percentile: 1.21//95%在1.21ms内完成sum: 59975.10Threads fairness:events (avg/stddev): 50212.0000/0.00execution time (avg/stddev): 59.9751/0.00

测试场景2:开启8个线程sysbench cpu --time=60 --threads=8 run

[root@localhost ~]# sysbench cpu --time=60 --threads=8 runsysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)Running the test with following options:Number of threads: 8Initializing random number generator from current timePrime numbers limit: 10000Initializing worker threads...Threads started!CPU speed:events per second: 3329.87//CPU速度General statistics:total time:60.0012s//运行时间60stotal number of events: 199802//60s内所有线程共执行199802次eventLatency (ms):min:1.18//最小耗时1.18msavg:2.40//平均耗时2.40msmax:67.19//最大耗时67.19ms95th percentile: 11.24//95%在11.24ms内完成sum: 479692.58Threads fairness:events (avg/stddev): 24975.2500/87.36execution time (avg/stddev): 59.9616/0.01

如果觉得《Linux服务器常见运维性能测试(3)CPU测试super_pi sysbench》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。