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

news2024/9/27 9:23:56

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不稳定导致的。
官方下载地址:https://superpi.ilbello.com/
解压后直接运行即可

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性能。

下载安装

下载地址: https://github.com/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,所以放弃依赖mysql
make  #最后执行汇编安装
make install  #安装完毕

查看版本安装成功
在这里插入图片描述

sysbench综合测试功能

查看帮助文档

sysbench --help
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],请求的最大数目,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=FILENAME          File containing command line options
  --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],日志级别,默认为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 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.

测试CPU的帮助文档

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

测试IO的帮助文档

# 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.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 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.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 help
sysbench 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]... 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 #指定测试类型。
fileio
cpu
memory
threads
mutex

--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 #IO
cpu - CPU performance test #CPU
memory - 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 run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Prime numbers limit: 10000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:   836.83			//	CPU速度

General statistics:
    total time:                          60.0004s  //运行时间60s
    total number of events:              50212		//60s内共执行50212次event

Latency (ms):
         min:                                    1.18 	//最小耗时1.18ms
         avg:                                    1.19	//平均耗时1.19ms
         max:                                    2.76	//最大耗时2.76ms
         95th percentile:                        1.21	//95%在1.21ms内完成
         sum:                                59975.10	

Threads fairness:
    events (avg/stddev):           50212.0000/0.00
    execution time (avg/stddev):   59.9751/0.00
测试场景2:开启8个线程
sysbench cpu --time=60 --threads=8 run
[root@localhost ~]# sysbench cpu --time=60 --threads=8 run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 8
Initializing random number generator from current time


Prime numbers limit: 10000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:  3329.87			//CPU速度

General statistics:
    total time:                          60.0012s		//运行时间60s
    total number of events:              199802			//60s内所有线程共执行199802次event

Latency (ms):
         min:                                    1.18	//最小耗时1.18ms
         avg:                                    2.40	//平均耗时2.40ms
         max:                                   67.19	//最大耗时67.19ms
         95th percentile:                       11.24	//95%在11.24ms内完成
         sum:                               479692.58

Threads fairness:
    events (avg/stddev):           24975.2500/87.36
    execution time (avg/stddev):   59.9616/0.01

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/175460.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Java面试题含答案,最新面试题(1)

Java 中 InvokeDynamic指令是干什么的&#xff1f; JVM字节码指令集一直比较稳定&#xff0c;一直到Java7中才增加了一个InvokeDynamic 指令&#xff0c;这是JAVA为了实现『动态类型语言』支持而做的一种改进&#xff1b;但是在Java7中并没有提供直接生成InvokeDynamic 指令的…

自定义类型:结构体,枚举,联合

目录一、结构体内存对齐二、位段2.1 什么是位段2.2 位段内存分配规则2.3 位段的跨平台问题三、枚举四、联合体4.1 联合类型的定义4.2联合的特点4.3 联合大小的计算4.4 练习一、结构体内存对齐 struct s {char c1;int i;char c2; }; int main() {printf("%d\n", size…

【Hadoop】HDFS体系结构分析

文章目录1. NameNode2. Secondary NameNode3. DataNodeHDFS主要包含NameNode、Secondary NameNode和DataNode三部分&#xff0c;且这三部分在分布式文件系统中分属不同的机器&#xff0c;其中Secondary NameNode不是必须的&#xff0c;在HA架构中Standby NameNode可以替代它。 …

【深度学习】详解 SimCLR

目录 摘要 一、引言 二、方法 2.1 The Contrastive Learning Framework 2.2. Training with Large Batch Size 2.3. Evaluation Protocol 三、用于对比表示学习的数据增广 3.1 Composition of data augmentation operations is crucial for learning good representa…

5-2中央处理器-指令周期的数据流

文章目录一.指令周期二.数据流向1.取指周期2.间址周期3.执行周期4.中断周期三.指令执行方案1.单指令周期2.多指令周期3.流水线方案一.指令周期 指令周期&#xff1a;CPU从主存中每取出并执行一条指令所需的全部时间。 此处&#xff1a;取指周期取指令指令译码 指令周期常用若…

SSM整合(Spring + SpringMVC + MyBatis)

SSM Spring SpringMVC MyBatis 准备数据库 SET FOREIGN_KEY_CHECKS0; DROP TABLE IF EXISTS user; CREATE TABLE user (id int(11) NOT NULL AUTO_INCREMENT,username varchar(20) NOT NULL COMMENT 用户名,password varchar(255) NOT NULL COMMENT 密码,real_name varchar(…

Linux常用命令——startx命令

在线Linux命令查询工具(http://www.lzltool.com/LinuxCommand) startx 用来启动X Window 补充说明 startx命令用来启动X Window&#xff0c;实际上启动X Window的程序为xinit。 语法 startx(参数)参数 客户端及选项&#xff1a;X客户端及选项&#xff1b;服务器及选项&a…

[LeetCode周赛复盘] 第 329 场周赛20230122

[LeetCode周赛复盘] 第 329 场周赛20230122 一、本周周赛总结二、 [Easy] 6296. 交替数字和1. 题目描述2. 思路分析3. 代码实现三、[Medium] 6297. 根据第 K 场考试的分数排序1. 题目描述2. 思路分析3. 代码实现四、[Medium] 6298. 执行逐位运算使字符串相等1. 题目描述2. 思路…

深入理解 OpenMP 线程同步机制

深入理解 OpenMP 线程同步机制 前言 在本篇文章当中主要给大家介绍 OpenMP 当中线程的同步和互斥机制&#xff0c;在 OpenMP 当中主要有三种不同的线程之间的互斥方式&#xff1a; 使用 critical 子句&#xff0c;使用这个子句主要是用于创建临界区和 OpenMP 提供的运行时库…

连续系统的数字PID控制仿真-1

被控对象为一电机模型传递函数&#xff1a;式中&#xff0c;J 0.0067;B0.10。采用M函数的形式&#xff0c;利用ODE45的方法求解连续对象方程&#xff0c;输入指令信号为yd(k)0.50sin(2*3.14*t)&#xff0c;采用PID控制方法设计控制器&#xff0c;其中kp20.0 ,kd0.50。PID正弦跟…

12个开源的后台管理系统

1. D2admin 开源地址&#xff1a;https://github.com/d2-projects/d2-admin 文档地址&#xff1a;https://d2.pub/zh/doc/d2-admin/ 效果预览&#xff1a;https://d2.pub/d2-admin/preview/#/index 开源协议&#xff1a;MIT 2. vue-element-admin 开源地址&#xff1a;htt…

Kettle(3):快速入门

1 需求 有一个txt文件&#xff0c;内容如下&#xff1a; id,name,age,gender,province,city,region,phone,birthday,hobby,register_date 392456197008193000,张三,20,0,北京市,昌平区,回龙观,18589407692,1970-8-19,美食;篮球;足球,2018-8-6 9:44 267456198006210000,李四,2…

Vue3 – Composition API

1、认识CompositionAPI 1.1、Options API的弊端 在Vue2中&#xff0c;我们编写组件的方式是Options API&#xff1a; Options API的一大特点就是在对应的属性中编写对应的功能模块&#xff1b;比如data定义数据、methods中定义方法、computed中定义计算属性、watch中监听属性…

【快速简单登录认证】SpringBoot使用Sa-Token-Quick-Login插件快速登录认证

一、解决的问题 Sa-Token-Quick-Login 可以为一个系统快速的、零代码 注入一个登录页面 试想一下&#xff0c;假如我们开发了一个非常简单的小系统&#xff0c;比如说&#xff1a;服务器性能监控页面&#xff0c; 我们将它部署在服务器上&#xff0c;通过访问这个页面&#xf…

学习字符串函数和内存函数必看

字符串函数 1.strlen函数 strlen库函数 #include<stdio.h> #include<string.h> int main() {char arr[] "abc";char arr1[] { a,b,c };int len strlen(arr);int len1 strlen(arr1);//没有\0就无法停止printf("%d\n",len);printf("%…

VUE中的provide和inject用法

一、Vue中 常见的组件通信方式可分为三类 父子通信 父向子传递数据是通过 props&#xff0c;子向父是通过 events&#xff08;$emit&#xff09;&#xff1b; 通过父链 / 子链也可以通信&#xff08;$parent / $children&#xff09;&#xff1b; ref 也可以访问组件实例&…

XLSReadWriteII 写了一个DBGrdiEh创建EXCEL表的函数

XLSReadWriteII 写了一个DBGrdiEh创建EXCEL表的函数 自己通过XLSReadWriteII&#xff0c;写了一个由DBGridEh数据集&#xff0c;通过参数调用&#xff0c;创建EXCEL表格的函数&#xff0c;通过调用的参数设置&#xff0c;可以较为方便地&#xff0c;创建指定数据集的常用EXCEL表…

自动化和Selenium

作者&#xff1a;~小明学编程 文章专栏&#xff1a;测试开发 格言&#xff1a;热爱编程的&#xff0c;终将被编程所厚爱。 目录 什么是自动化&#xff0c;我们为什么需要自动化的测试&#xff1f; 为什么选择selenium来作为我们的web自动化测试的工具&#xff1f; 定位元素…

【C进阶】找单身狗

⭐博客主页&#xff1a;️CS semi主页 ⭐欢迎关注&#xff1a;点赞收藏留言 ⭐系列专栏&#xff1a;C语言进阶 ⭐代码仓库&#xff1a;C Advanced 家人们更新不易&#xff0c;你们的点赞和关注对我而言十分重要&#xff0c;友友们麻烦多多点赞&#xff0b;关注&#xff0c;你们…

Spring事务(事务的实现、隔离级别、传播机制)

目录 一、事务的定义和意义 二、事务的实现 1、MySQL事务的回顾 2、Spring声明式事务&#xff08;利⽤注解⾃动开启和提交事务&#xff09; 前置知识及概念 实例分析&#xff1a;事务的回滚 &#x1f514;特殊情况&#xff08;无自动回滚&#xff09; &#x1f514;事务…