读取系统中的 CPU 的提供商和参数信息,则可以通过/proc/cpuinfo 文件得到。
root@myir-yg2lx:~# cat /proc/cpuinfo
processor : 0
BogoMIPS : 48.00
Features : fp asimd evtstrm crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x2
CPU part : 0xd05
CPU revision : 0
processor : 1
BogoMIPS : 48.00
Features : fp asimd evtstrm crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x2
CPU part : 0xd05
CPU revision : 0
2. 查看CPU占用情况:
root@myir-yg2lx:~# top
top - 00:24:41 up 24 min, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 107 total, 1 running, 106 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.3 us, 0.5 sy, 0.0 ni, 98.8 id, 0.0 wa, 0.2 hi, 0.2 si, 0.0 st
MiB Mem : 855.9 total, 430.8 free, 209.8 used, 215.4 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 570.4 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
358 root 20 0 362852 70344 36348 S 0.7 8.0 0:12.13 mxapp2
548 root 20 0 4616 2460 2020 R 0.7 0.3 0:00.07 top
7 root 20 0 0 0 0 I 0.3 0.0 0:01.29 kworker+
110 root 20 0 0 0 0 I 0.3 0.0 0:01.38 kworker+
222 root 20 0 1784 412 348 S 0.3 0.0 0:00.18 watchdo+
387 root 20 0 1432744 77964 35256 S 0.3 8.9 0:07.42 dockerd
396 root 20 0 1328624 45456 18588 S 0.3 5.2 0:06.68 contain+
1 root 20 0 10352 7564 5036 S 0.0 0.9 0:05.77 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par+
8 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_perc+
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_tas+
10 root 20 0 0 0 0 S 0.0 0.0 0:00.16 ksoftir+
11 root 20 0 0 0 0 I 0.0 0.0 0:00.36 rcu_pre+
12 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migrati+
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
3. 获取 CPU 温度信息
root@myir-yg2lx:~# cat /sys/class/thermal/thermal_zone0/temp
47000
查询到的数值除以1000就得到实际的度数。
4. 计算圆周率:
root@myir-yg2lx:~# cat /proc/meminfo
MemTotal: 876452 kB
MemFree: 476080 kB
MemAvailable: 619184 kB
Buffers: 5788 kB
Cached: 201480 kB
SwapCached: 0 kB
Active: 27224 kB
Inactive: 278828 kB
Active(anon): 608 kB
Inactive(anon): 106696 kB
Active(file): 26616 kB
Inactive(file): 172132 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 4 kB
Writeback: 0 kB
AnonPages: 98852 kB
Mapped: 70956 kB
Shmem: 10436 kB
KReclaimable: 12612 kB
Slab: 71732 kB
SReclaimable: 12612 kB
SUnreclaim: 59120 kB
KernelStack: 3232 kB
PageTables: 2092 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 438224 kB
Committed_AS: 1093704 kB
VmallocTotal: 135290159040 kB
VmallocUsed: 4708 kB
VmallocChunk: 0 kB
Percpu: 680 kB
AnonHugePages: 36864 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
CmaTotal: 393216 kB
CmaFree: 238040 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
6. 获取内存使用率
7. 内存压力测试
root@myir-yg2lx:~# memtester 100M 5
memtester version 4.3.0 (64-bit)
Copyright (C) 2001-2012 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).
pagesize is 4096
pagesizemask is 0xfffffffffffff000
want 100MB (104857600 bytes)
got 100MB (104857600 bytes), trying mlock ...locked.
Loop 1/5:
Stuck Address : ok
Random Value : ok
Compare XOR : ok
Compare SUB : ok
Compare MUL : ok
Compare DIV : ok
Compare OR : ok
Compare AND : ok
Sequential Increment: ok
Solid Bits : ok
Block Sequential : ok
Checkerboard : ok
Bit Spread : ok
Bit Flip : ok
Walking Ones : ok
Walking Zeroes : ok
Loop 2/5:
Stuck Address : ok
Random Value : ok
Compare XOR : ok
Compare SUB : ok
Compare MUL : ok
Compare DIV : ok
Compare OR : ok
Compare AND : ok
Sequential Increment: ok
Solid Bits : ok
Block Sequential : ok
Checkerboard : ok
Bit Spread : ok
Bit Flip : ok
Walking Ones : ok
Walking Zeroes : ok
Loop 3/5:
Stuck Address : ok
Random Value : ok
Compare XOR : ok
Compare SUB : ok
Compare MUL : ok
Compare DIV : ok
Compare OR : ok
Compare AND : ok
Sequential Increment: ok
Solid Bits : ok
Block Sequential : ok
Checkerboard : ok
Bit Spread : ok
Bit Flip : ok
Walking Ones : ok
Walking Zeroes : ok
Loop 4/5:
Stuck Address : ok
Random Value : ok
Compare XOR : ok
Compare SUB : ok
Compare MUL : ok
Compare DIV : ok
Compare OR : ok
Compare AND : ok
Sequential Increment: ok
Solid Bits : ok
Block Sequential : ok
Checkerboard : ok
Bit Spread : ok
Bit Flip : ok
Walking Ones : ok
Walking Zeroes : ok
Loop 5/5:
Stuck Address : ok
Random Value : ok
Compare XOR : ok
Compare SUB : ok
Compare MUL : ok
Compare DIV : ok
Compare OR : ok
Compare AND : ok
Sequential Increment: ok
Solid Bits : ok
Block Sequential : ok
Checkerboard : ok
Bit Spread : ok
Bit Flip : ok
Walking Ones : ok
Walking Zeroes : ok
Done.
通过上述看到,内存压力测试通过。