mikebai.com

  • Home
  • dev
  • DotNET
  • M365
  • 搞笑
  • 杂七杂八
  • FocusDict
個人BLOG
it developer
  1. Main page
  2. M365
  3. Main content

cpu负荷测试工具和使用方法

2020-11-18 124hotness 0likes 0comments

通过cpuburn工具可以对CPU内核进行压力测试。

支持系统:

Linux (32-bit)、Linux (64-bit)、Windows

工具官网地址: 

https://patrickmn.com/projects/cpuburn/

使用案例:

以CentOS 6.5 64bit为例使用cpuburn工具,进行CPU的压力测试,并查看CU中的CPU监控图。

1.下载解压工具

*Linux 64 bit OS下载方式

wget https://cdn.pmylund.com/files/tools/cpuburn/linux/cpuburn-1.0-amd64.tar.gz

* Linux 32 bit OS 下载地址

https://cdn.pmylund.com/files/tools/cpuburn/linux/cpuburn-1.0-i386.tar.gz

*Windows OS下载地址

https://cdn.pmylund.com/files/tools/cpuburn/windows/cpuburn-1.0.zip

-----------------------------测试方法-----------------------

windows

拷贝执行文件到测试电脑执行即可

 

linux

#执行以下命令

sudo su -

mkdir -p -m 777  /usr/hakutest;

cd /usr/hakutest/

wget https://cdn.pmylund.com/files/tools/cpuburn/linux/cpuburn-1.0-amd64.tar.gz

ls

tar xvzf cpuburn-1.0-amd64.tar.gz

ls

cd /usr/hakutest/cpuburn/

# 执行

./cpuburn Burn all available cores

./cpuburn -n 2 Burn two cores

./cpuburn -n 2 -u 5 Burn two cores, sending an update every five seconds

内存

1.LINUX环境下测试

sudo su -

mkdir -p -m 777  /usr/hakutest;

cd /usr/hakutest/

wget http://pyropus.ca/software/memtester/old-versions/memtester-4.2.2.tar.gz

ls

tar xvzf memtester-4.2.2.tar.gz

ls

cd /usr/hakutest/memtester-4.2.2 /

# 执行安装

make && make install

# 会生成一个memtester文件的,然后运行:

# memtester [-p PHYSADDR] <MEMORY> [ITERATIONS]

# MEMORY 申请测试内存的数量,单位默认是megabytes(兆),也可以是B K M G

# ITERATIONS 测试的次数,默认是无限

./memtester 2048 10

https://blog.csdn.net/cangencong/article/details/74328944

用法

./shell.sh 4 (4为4内核)

查看cpu内核数量 > lscpu

执行后会出现一堆kill命令,方便kill掉进程

#!/bin/bash  

endless_loop()  

{  

echo -ne "i=0; 

while true 

do 

i=i+100; 

i=100done" | /bin/bash &  

}  

if [ $# != 1 ]; then  

echo "USAGE: $0 <cpus>"  

exit 1;  

fi  

  

for i in `seq $1`  

do  

endless_loop  

pid_array[$i]=$!;  

done  

  

for i in "${pid_array[@]}"; do  

echo 'kill' $i ';';  

done  

shell消耗内存

以前有过[shell消耗cpu][1]的文章,再记录一个shell消耗内存代码。

#!/bin/bash  

mkdir /tmp/memory  

mount -t tmpfs -o size=1024M tmpfs /tmp/memory  

dd if=/dev/zero of=/tmp/memory/block  

sleep 3600  

rm /tmp/memory/block  

umount /tmp/memory  

rmdir /tmp/memory  

用tmpfs文件系统占用内存一个小时

Tag: Nothing
Last updated:2020-11-18

mikebai

This person is a lazy dog and has left nothing

Like
< Last article
Next article >

COPYRIGHT © 2025 mikebai.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang