searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

lmbench工具的自动化测试实现

2023-06-28 02:39:34
70
0

一 概述

Lmbench是个多平台软件,因此能够对同级别的系统进行比较测试,反映不同系统的优劣势,可用于评价系统综合性能的多平台开源benchmark,能够测试包括文档读写、内存操作、进程创建销毁开销、网络等性能,测试方法简单。通过选择不同的库函数我们就能够比较库函数的性能;更为重要的是,作为一个开源软件,lmbench提供一个测试框架,假如测试者对测试项目有更高的测试需要,能够通过少量的修改源代码达到目的。测试系统调用时间,shell命令启动时间,系统信号处理时间,上下文切换性能等。

二 测试前提

  • 需要安装依赖
yum install -y gcc gcc-c++ libtirpc-devel
  • 获取源码包
wget https://nchc.dl.sourceforge.net/project/lmbench/development/lmbench-3.0-a9/lmbench-3.0-a9.tgz

三 测试步骤

  • 解压lmbench3源码包以后cd 切换到lmbench源码目录
  • 修改scripts/build脚本,在LDLIBS=-lm下面添加LDLIBS="${LDLIBS} -ltirpc"              CFLAGS="${CFLAGS} -I/usr/include/tirpc"两行
  • 修改scripts/gnu-os脚本,将165、173、830行的arm*改为aarch64*
  • 执行make OS=x86 results/make OS=arm64 results测试,并在测试完成后make see查看测试结果,Lmbench测试成功并在results下生成summary.out的测试结果

四 自动化测试

  • 安装的代码片段
       ...
        if ENV.osName() in ['ctyunos', 'openeuler']:
            # LDLIBS = "${LDLIBS} -ltirpc"
            # CFLAGS = "${CFLAGS} -I/usr/include/tirpc"
            host.run(f"""cd {cls.unzip_path}; sed -i "s/-lm/\\"\\${'{LDLIBS}'} -ltirpc\\"\\nCFLAGS=\\"\\${'{CFLAGS}'} -I\\/usr\\/include\\/tirpc\\"/g" scripts/build""")
        if ENV.get_gcc_version() == '7.3.0':
            sed_cmd = """sed -i "s/llseek/lseek64/g" ./src/disk.c"""
            host.run(f"cd {cls.unzip_path};{sed_cmd}")
        cls.arch = ENV.get_arch()
        if cls.arch == 'aarch64':
            host.run(f"cd {cls.unzip_path};sed -i 's/arm\\*/aarch64\\*/' scripts/gnu-os")
        ...
  • 在进行测试前需要进行配置,以配置测试参数以及获取测试环境的信息(如测试size、cpu频率等等),配置脚本在 lmbench3/scripts 目录下,名字叫config-run。在lmbench目录下,执行make results,根据屏幕提示,输入的内容会生成测试配置文件,在bin/{arch}/CONFIG.{hostname}
DISKS=""
DISK_DESC=""
OUTPUT=/dev/tty
ENOUGH=5000
FASTMEM="NO"
FILE=/usr/tmp/XXX
FSDIR=/usr/tmp
INFO=INFO.gzinf-kunpeng-55e235e17e49
LINE_SIZE=128
LOOP_O=0.00000000
MAIL=no
TOTAL_MEM=191869
MB=100
MHZ="2599 MHz, 0.3848 nanosec clock"
MOTHERBOARD=""
NETWORKS=""
OS="aarch64-linux-gnu"
PROCESSORS="96"
REMOTE=""
SLOWFS="NO"
SYNC_MAX="1"
LMBENCH_SCHED="DEFAULT"
TIMING_O=0
RSH=rsh
RCP=rcp
VERSION=3.0-a9
BENCHMARK_HARDWARE=YES
BENCHMARK_OS=YES
BENCHMARK_SYSCALL=
BENCHMARK_SELECT=
BENCHMARK_SIG=
BENCHMARK_PROC=
BENCHMARK_CTX=
BENCHMARK_PAGEFAULT=
BENCHMARK_FILE=
BENCHMARK_MMAP=
BENCHMARK_PIPE=
BENCHMARK_UNIX=
BENCHMARK_UDP=
BENCHMARK_TCP=
BENCHMARK_CONNECT=
BENCHMARK_RPC=
BENCHMARK_HTTP=
BENCHMARK_BCOPY=
BENCHMARK_MEM=
BENCHMARK_OPS=

在需要测试的benchmark项填入yes即可

  • 编译成功后,在bin/{arch}/目录下会一个lmbench的执行文件,测试具体的lmbench测试项,只需在lmbench执行文件后接对应的benchmark配置文件。如./lmbench file.conf,测试结果如下
Using config in /tmp/lmbench-3.0-a9/file_1.config
[lmbench3.0 results for Linux gzinf-kunpeng-55e235e17e49 5.10.0-136.12.0.86.ctl3.aarch64 #1 SMP Fri Jan 13 08:18:45 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux]
[LMBENCH_VER: 3.0-a9]
[BENCHMARK_HARDWARE: NO]
[BENCHMARK_OS: NO]
[ALL: 512 1k 2k 4k 8k 16k 32k 64k 128k 256k 512k 1m 2m 4m 8m 16m 32m 64m 128m 256m 512m 1024m]
[DISKS: ]
[DISK_DESC: ]
[ENOUGH: 5000]
[FAST: ]
[FASTMEM: YES]
[FILE: /usr/tmp/lmbench/XXX]
[FSDIR: /usr/tmp/lmbench]
[HALF: 512 1k 2k 4k 8k 16k 32k 64k 128k 256k 512k 1m 2m 4m 8m 16m 32m 64m 128m 256m 512m]
[INFO: INFO.gzinf-kunpeng-55e235e17e49]
[LINE_SIZE: 128]
[LOOP_O: 0.00000000]
[MB: 1024]
[MHZ: 2599 MHz, 0.3848 nanosec clock]
[MOTHERBOARD: ]
[NETWORKS: ]
[PROCESSORS: 96]
[REMOTE: ]
[SLOWFS: NO]
[OS: aarch64-Linux]
[SYNC_MAX: 1]
[LMBENCH_SCHED: DEFAULT]
[TIMING_O: 0]
[LMBENCH VERSION: 3.0-a9]
[USER: root]
[HOSTNAME: gzinf-kunpeng-55e235e17e49]
[NODENAME: gzinf-kunpeng-55e235e17e49]
[SYSNAME: Linux]
[PROCESSOR: aarch64]
[MACHINE: aarch64]
[RELEASE: 5.10.0-136.12.0.86.ctl3.aarch64]
[VERSION: #1 SMP Fri Jan 13 08:18:45 UTC 2023]
[Fri May 19 03:17:29 PM CST 2023]
[ 15:17:29 up 29 days, 4:23, 4 users, load average: 0.37, 0.13, 0.04]
[net: Kernel Interface table]
[net: Iface             MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg]
[net: bond0            1500 43273632      0 168056 0      12074946      0      0      0 BMmRU]
[if: bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500]
[if: inet6 fe80::4600:4dff:fea7:a20c  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:a7:a2:0c  txqueuelen 1000  (Ethernet)]
[if: RX packets 43273635  bytes 4161690578 (3.8 GiB)]
[if: RX errors 0  dropped 168056  overruns 0  frame 0]
[if: TX packets 12074949  bytes 985842421 (940.1 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: bond1            9000  6947699      0      0 0       4855182      0      5      0 BMmRU]
[if: bond1: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 9000]
[if: inet6 fe80::4600:4dff:fe65:4869  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:65:48:69  txqueuelen 1000  (Ethernet)]
[if: RX packets 6947700  bytes 731607464 (697.7 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 4855183  bytes 601524172 (573.6 MiB)]
[if: TX errors 0  dropped 5 overruns 0  carrier 0  collisions 0]
[if: ]
[net: bond2            9000  5519471      0      0 0       4848254      0      9      0 BMmRU]
[if: bond2: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 9000]
[if: inet6 fe80::4600:4dff:fe65:486a  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:65:48:6a  txqueuelen 1000  (Ethernet)]
[if: RX packets 5519471  bytes 651626572 (621.4 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 4848254  bytes 601108118 (573.2 MiB)]
[if: TX errors 0  dropped 9 overruns 0  carrier 0  collisions 0]
[if: ]
[net: bond0.3830       1500  3901058      0      0 0       2198467      0      0      0 BMRU]
[if: bond0.3830: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500]
[if: inet 55.235.17.49  netmask 255.255.240.0  broadcast 55.235.31.255]
[if: inet6 fe80::4600:4dff:fea7:a20c  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:a7:a2:0c  txqueuelen 1000  (Ethernet)]
[if: RX packets 3901070  bytes 323090700 (308.1 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 2198497  bytes 395045237 (376.7 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: bond1.521        9000  1910401      0      3 0          7624      0      3      0 BMRU]
[if: bond1.521: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9000]
[if: inet 55.235.37.49  netmask 255.255.224.0  broadcast 55.235.63.255]
[if: inet6 fe80::4600:4dff:fe65:4869  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:65:48:69  txqueuelen 1000  (Ethernet)]
[if: RX packets 1910402  bytes 80236884 (76.5 MiB)]
[if: RX errors 0  dropped 3  overruns 0  frame 0]
[if: TX packets 7624  bytes 339912 (331.9 KiB)]
[if: TX errors 0  dropped 3 overruns 0  carrier 0  collisions 0]
[if: ]
[net: bond2.520        9000   482174      0      0 0           700      0      5      0 BMRU]
[if: bond2.520: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9000]
[if: inet 55.235.67.49  netmask 255.255.240.0  broadcast 55.235.79.255]
[if: inet6 fe80::4600:4dff:fe65:486a  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:65:48:6a  txqueuelen 1000  (Ethernet)]
[if: RX packets 482174  bytes 20251308 (19.3 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 700  bytes 48984 (47.8 KiB)]
[if: TX errors 0  dropped 5 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens0             1500 22096100      0      2 0       6925446      0      0      0 BMsRU]
[if: ens0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:a7:a2:0c  txqueuelen 1000  (Ethernet)]
[if: RX packets 22096121  bytes 2102609283 (1.9 GiB)]
[if: RX errors 0  dropped 2  overruns 0  frame 0]
[if: TX packets 6925506  bytes 670102620 (639.0 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens1             1500 21177532      0  84030 0       5149500      0      0      0 BMsRU]
[if: ens1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:a7:a2:0d  txqueuelen 1000  (Ethernet)]
[if: RX packets 21177533  bytes 2059082537 (1.9 GiB)]
[if: RX errors 0  dropped 84030  overruns 0  frame 0]
[if: TX packets 5149500  bytes 315750267 (301.1 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens2             9000  3014003      0      0 0       2427369      0      0      0 BMsRU]
[if: ens2: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 9000]
[if: ether 44:00:4d:65:48:69  txqueuelen 1000  (Ethernet)]
[if: RX packets 3014004  bytes 340052424 (324.2 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 2427370  bytes 300741972 (286.8 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens3             9000  3933696      0      0 0       2427813      0      0      0 BMsRU]
[if: ens3: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 9000]
[if: ether 44:00:4d:65:48:69  txqueuelen 1000  (Ethernet)]
[if: RX packets 3933696  bytes 391555040 (373.4 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 2427813  bytes 300782200 (286.8 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens4             9000  2519503      0      0 0       2424826      0      0      0 BMsRU]
[if: ens4: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 9000]
[if: ether 44:00:4d:65:48:6a  txqueuelen 1000  (Ethernet)]
[if: RX packets 2519503  bytes 312360368 (297.8 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 2424826  bytes 300603046 (286.6 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens5             9000  2999968      0      0 0       2423428      0      0      0 BMsRU]
[if: ens5: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 9000]
[if: ether 44:00:4d:65:48:6a  txqueuelen 1000  (Ethernet)]
[if: RX packets 2999968  bytes 339266204 (323.5 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 2423429  bytes 300505196 (286.5 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth2             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth2: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:a7:a2:0e  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth3             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth3: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:a7:a2:0f  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth4             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth4: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:65:48:6b  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth5             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth5: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:65:48:6c  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth8             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth8: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:65:48:3b  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth9             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth9: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:65:48:3c  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: lo              65536 302881169      0   2985 0      302881169      0      0      0 LRU]
[if: lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536]
[if: inet 127.0.0.1  netmask 255.0.0.0]
[if: inet6 ::1  prefixlen 128  scopeid 0x10<host>]
[if: loop  txqueuelen 1000  (Local Loopback)]
[if: RX packets 302881169  bytes 4082730699199 (3.7 TiB)]
[if: RX errors 0  dropped 2985  overruns 0  frame 0]
[if: TX packets 302881169  bytes 4082730699199 (3.7 TiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ltp_ns_veth2      552 107227919      0     72 0      57053147      0     43      0 BMRU]
[if: ltp_ns_veth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 552]
[if: inet 10.0.0.2  netmask 255.255.255.0  broadcast 0.0.0.0]
[if: ether aa:31:fd:7c:7f:b1  txqueuelen 1000  (Ethernet)]
[if: RX packets 107227919  bytes 45168157126 (42.0 GiB)]
[if: RX errors 0  dropped 72  overruns 0  frame 0]
[if: TX packets 57053147  bytes 53687217113 (50.0 GiB)]
[if: TX errors 0  dropped 43 overruns 0  carrier 0  collisions 0]
[if: ]
[mount: proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)]
[mount: sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)]
[mount: devtmpfs on /dev type devtmpfs (rw,nosuid,size=4096k,nr_inodes=1048576,mode=755)]
[mount: securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)]
[mount: tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)]
[mount: devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)]
[mount: tmpfs on /run type tmpfs (rw,nosuid,nodev,size=39294844k,nr_inodes=819200,mode=755)]
[mount: tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755)]
[mount: cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)]
[mount: pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)]
[mount: efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)]
[mount: none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)]
[mount: cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)]
[mount: cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)]
[mount: cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)]
[mount: cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)]
[mount: cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)]
[mount: cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)]
[mount: cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)]
[mount: cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)]
[mount: cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)]
[mount: cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)]
[mount: cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)]
[mount: /dev/sda4 on / type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,sunit=512,swidth=512,noquota)]
[mount: systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=19596)]
[mount: hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)]
[mount: mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)]
[mount: debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)]
[mount: tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)]
[mount: tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=98237104k,nr_inodes=1048576)]
[mount: fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)]
[mount: configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)]
[mount: ramfs on /run/credentials/systemd-sysusers.service type ramfs (ro,nosuid,nodev,noexec,relatime,mode=700)]
[mount: /dev/sda5 on /var type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,sunit=512,swidth=512,noquota)]
[mount: /dev/sda3 on /boot type ext2 (rw,relatime,stripe=64)]
[mount: /dev/sda2 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)]
[mount: sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)]
[mount: binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)]
[mount: tracefs on /sys/kernel/debug/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)]
[mount: tmpfs on /run/netns type tmpfs (rw,nosuid,nodev,size=39294844k,nr_inodes=819200,mode=755)]
[mount: cgroup2 on /tmp/ltp-kdfmLs9sNa/cgroup_unified type cgroup2 (rw,relatime,memory_recursiveprot)]
[mount: nsfs on /run/netns/tst_net_ns0 type nsfs (rw)]
[mount: nsfs on /run/netns/tst_net_ns0 type nsfs (rw)]
[mount: nsfs on /run/netns/tst_net_ns1 type nsfs (rw)]
[mount: nsfs on /run/netns/tst_net_ns1 type nsfs (rw)]
[mount: /dev/sdb1 on /fs/sdb1 type ext4 (rw,relatime,stripe=64)]
[mount: nfsd on /proc/fs/nfsd type nfsd (rw,relatime)]
Fri May 19 03:17:29 PM CST 2023
Latency measurements
File /usr/tmp/lmbench/XXX write bandwidth: 1337511 KB/sec
Fri May 19 03:17:30 PM CST 2023
Calculating file system latency
"File system latency
0k	439	78365	93876
1k	307	53690	84045
4k	314	55605	66696
10k	277	40133	72167

Fri May 19 03:17:32 PM CST 2023
Local networking
Fri May 19 03:17:35 PM CST 2023
Bandwidth measurements

"read bandwidth
0.000512 715.30
0.001024 1368.44
0.002048 2435.24
0.004096 3900.39
0.008192 5491.16
0.016384 6692.98
0.032768 7214.43
0.065536 7390.03
0.131072 7459.19
0.262144 7253.94
0.524288 6483.28
1.05 5971.60
2.10 5873.35
4.19 5818.35
8.39 5365.28
16.78 4432.55
33.55 4168.77
67.11 3865.72
134.22 3958.06
268.44 4058.29
536.87 4194.40
1073.74 4304.89

"read open2close bandwidth
0.000512 196.34
0.001024 389.45
0.002048 771.42
0.004096 1448.43
0.008192 2404.43
0.016384 3735.17
0.032768 5010.60
0.065536 6017.28
0.131072 6635.04
0.262144 6670.33
0.524288 6179.28
1.05 5825.42
2.10 5803.26
4.19 5766.36
8.39 5337.11
16.78 4439.59
33.55 4186.45
67.11 3865.72
134.22 3953.63
268.44 4062.53
536.87 4194.60
1073.74 4305.94

Fri May 19 03:17:51 PM CST 2023

[Fri May 19 03:17:51 PM CST 2023]
  • 利用正则表达式对上面的测试结果进行处理,代码片段如下
#rtfile:lmbench测试结果文件
#case:lmbench的测试项,对应benchmark
...
with open(rtfile, 'r') as f:
            lines = "".join(f.readlines())
        regex = r"\n([\w\W]*?)\n\n"
        if 'file' in case:
            file_latency = re.compile(f"File system latency{regex}").findall(lines)[-1].split('\n')
            data.setdefault(case,{})['file_create_0k'] = format(1000 / int(file_latency[0].split('\t')[2]) * 1000, '.4f')
            data.setdefault(case,{})['file_delete_0k'] = format(1000 / int(file_latency[0].split('\t')[3]) * 1000, '.4f')
            data.setdefault(case,{})['file_create_10k'] = format(10 * 1000 / int(file_latency[-1].split('\t')[2]) * 1000, '.4f')
            data.setdefault(case,{})['file_delete_10k'] = format(10 * 1000 / int(file_latency[-1].split('\t')[3]) * 1000, '.4f')
            data.setdefault(case,{})['read_bandwidth'] = re.compile(f"read bandwidth{regex}").findall(lines)[-1].split('\n')[-1].split()[-1]
            data.setdefault(case,{})['read_open2close_bandwidth'] = re.compile(f"read open2close bandwidth{regex}").findall(lines)[-1].split('\n')[-1].split()[-1]
...

 

0条评论
0 / 1000
w****n
2文章数
0粉丝数
w****n
2 文章 | 0 粉丝
w****n
2文章数
0粉丝数
w****n
2 文章 | 0 粉丝
原创

lmbench工具的自动化测试实现

2023-06-28 02:39:34
70
0

一 概述

Lmbench是个多平台软件,因此能够对同级别的系统进行比较测试,反映不同系统的优劣势,可用于评价系统综合性能的多平台开源benchmark,能够测试包括文档读写、内存操作、进程创建销毁开销、网络等性能,测试方法简单。通过选择不同的库函数我们就能够比较库函数的性能;更为重要的是,作为一个开源软件,lmbench提供一个测试框架,假如测试者对测试项目有更高的测试需要,能够通过少量的修改源代码达到目的。测试系统调用时间,shell命令启动时间,系统信号处理时间,上下文切换性能等。

二 测试前提

  • 需要安装依赖
yum install -y gcc gcc-c++ libtirpc-devel
  • 获取源码包
wget https://nchc.dl.sourceforge.net/project/lmbench/development/lmbench-3.0-a9/lmbench-3.0-a9.tgz

三 测试步骤

  • 解压lmbench3源码包以后cd 切换到lmbench源码目录
  • 修改scripts/build脚本,在LDLIBS=-lm下面添加LDLIBS="${LDLIBS} -ltirpc"              CFLAGS="${CFLAGS} -I/usr/include/tirpc"两行
  • 修改scripts/gnu-os脚本,将165、173、830行的arm*改为aarch64*
  • 执行make OS=x86 results/make OS=arm64 results测试,并在测试完成后make see查看测试结果,Lmbench测试成功并在results下生成summary.out的测试结果

四 自动化测试

  • 安装的代码片段
       ...
        if ENV.osName() in ['ctyunos', 'openeuler']:
            # LDLIBS = "${LDLIBS} -ltirpc"
            # CFLAGS = "${CFLAGS} -I/usr/include/tirpc"
            host.run(f"""cd {cls.unzip_path}; sed -i "s/-lm/\\"\\${'{LDLIBS}'} -ltirpc\\"\\nCFLAGS=\\"\\${'{CFLAGS}'} -I\\/usr\\/include\\/tirpc\\"/g" scripts/build""")
        if ENV.get_gcc_version() == '7.3.0':
            sed_cmd = """sed -i "s/llseek/lseek64/g" ./src/disk.c"""
            host.run(f"cd {cls.unzip_path};{sed_cmd}")
        cls.arch = ENV.get_arch()
        if cls.arch == 'aarch64':
            host.run(f"cd {cls.unzip_path};sed -i 's/arm\\*/aarch64\\*/' scripts/gnu-os")
        ...
  • 在进行测试前需要进行配置,以配置测试参数以及获取测试环境的信息(如测试size、cpu频率等等),配置脚本在 lmbench3/scripts 目录下,名字叫config-run。在lmbench目录下,执行make results,根据屏幕提示,输入的内容会生成测试配置文件,在bin/{arch}/CONFIG.{hostname}
DISKS=""
DISK_DESC=""
OUTPUT=/dev/tty
ENOUGH=5000
FASTMEM="NO"
FILE=/usr/tmp/XXX
FSDIR=/usr/tmp
INFO=INFO.gzinf-kunpeng-55e235e17e49
LINE_SIZE=128
LOOP_O=0.00000000
MAIL=no
TOTAL_MEM=191869
MB=100
MHZ="2599 MHz, 0.3848 nanosec clock"
MOTHERBOARD=""
NETWORKS=""
OS="aarch64-linux-gnu"
PROCESSORS="96"
REMOTE=""
SLOWFS="NO"
SYNC_MAX="1"
LMBENCH_SCHED="DEFAULT"
TIMING_O=0
RSH=rsh
RCP=rcp
VERSION=3.0-a9
BENCHMARK_HARDWARE=YES
BENCHMARK_OS=YES
BENCHMARK_SYSCALL=
BENCHMARK_SELECT=
BENCHMARK_SIG=
BENCHMARK_PROC=
BENCHMARK_CTX=
BENCHMARK_PAGEFAULT=
BENCHMARK_FILE=
BENCHMARK_MMAP=
BENCHMARK_PIPE=
BENCHMARK_UNIX=
BENCHMARK_UDP=
BENCHMARK_TCP=
BENCHMARK_CONNECT=
BENCHMARK_RPC=
BENCHMARK_HTTP=
BENCHMARK_BCOPY=
BENCHMARK_MEM=
BENCHMARK_OPS=

在需要测试的benchmark项填入yes即可

  • 编译成功后,在bin/{arch}/目录下会一个lmbench的执行文件,测试具体的lmbench测试项,只需在lmbench执行文件后接对应的benchmark配置文件。如./lmbench file.conf,测试结果如下
Using config in /tmp/lmbench-3.0-a9/file_1.config
[lmbench3.0 results for Linux gzinf-kunpeng-55e235e17e49 5.10.0-136.12.0.86.ctl3.aarch64 #1 SMP Fri Jan 13 08:18:45 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux]
[LMBENCH_VER: 3.0-a9]
[BENCHMARK_HARDWARE: NO]
[BENCHMARK_OS: NO]
[ALL: 512 1k 2k 4k 8k 16k 32k 64k 128k 256k 512k 1m 2m 4m 8m 16m 32m 64m 128m 256m 512m 1024m]
[DISKS: ]
[DISK_DESC: ]
[ENOUGH: 5000]
[FAST: ]
[FASTMEM: YES]
[FILE: /usr/tmp/lmbench/XXX]
[FSDIR: /usr/tmp/lmbench]
[HALF: 512 1k 2k 4k 8k 16k 32k 64k 128k 256k 512k 1m 2m 4m 8m 16m 32m 64m 128m 256m 512m]
[INFO: INFO.gzinf-kunpeng-55e235e17e49]
[LINE_SIZE: 128]
[LOOP_O: 0.00000000]
[MB: 1024]
[MHZ: 2599 MHz, 0.3848 nanosec clock]
[MOTHERBOARD: ]
[NETWORKS: ]
[PROCESSORS: 96]
[REMOTE: ]
[SLOWFS: NO]
[OS: aarch64-Linux]
[SYNC_MAX: 1]
[LMBENCH_SCHED: DEFAULT]
[TIMING_O: 0]
[LMBENCH VERSION: 3.0-a9]
[USER: root]
[HOSTNAME: gzinf-kunpeng-55e235e17e49]
[NODENAME: gzinf-kunpeng-55e235e17e49]
[SYSNAME: Linux]
[PROCESSOR: aarch64]
[MACHINE: aarch64]
[RELEASE: 5.10.0-136.12.0.86.ctl3.aarch64]
[VERSION: #1 SMP Fri Jan 13 08:18:45 UTC 2023]
[Fri May 19 03:17:29 PM CST 2023]
[ 15:17:29 up 29 days, 4:23, 4 users, load average: 0.37, 0.13, 0.04]
[net: Kernel Interface table]
[net: Iface             MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg]
[net: bond0            1500 43273632      0 168056 0      12074946      0      0      0 BMmRU]
[if: bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500]
[if: inet6 fe80::4600:4dff:fea7:a20c  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:a7:a2:0c  txqueuelen 1000  (Ethernet)]
[if: RX packets 43273635  bytes 4161690578 (3.8 GiB)]
[if: RX errors 0  dropped 168056  overruns 0  frame 0]
[if: TX packets 12074949  bytes 985842421 (940.1 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: bond1            9000  6947699      0      0 0       4855182      0      5      0 BMmRU]
[if: bond1: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 9000]
[if: inet6 fe80::4600:4dff:fe65:4869  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:65:48:69  txqueuelen 1000  (Ethernet)]
[if: RX packets 6947700  bytes 731607464 (697.7 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 4855183  bytes 601524172 (573.6 MiB)]
[if: TX errors 0  dropped 5 overruns 0  carrier 0  collisions 0]
[if: ]
[net: bond2            9000  5519471      0      0 0       4848254      0      9      0 BMmRU]
[if: bond2: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 9000]
[if: inet6 fe80::4600:4dff:fe65:486a  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:65:48:6a  txqueuelen 1000  (Ethernet)]
[if: RX packets 5519471  bytes 651626572 (621.4 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 4848254  bytes 601108118 (573.2 MiB)]
[if: TX errors 0  dropped 9 overruns 0  carrier 0  collisions 0]
[if: ]
[net: bond0.3830       1500  3901058      0      0 0       2198467      0      0      0 BMRU]
[if: bond0.3830: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500]
[if: inet 55.235.17.49  netmask 255.255.240.0  broadcast 55.235.31.255]
[if: inet6 fe80::4600:4dff:fea7:a20c  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:a7:a2:0c  txqueuelen 1000  (Ethernet)]
[if: RX packets 3901070  bytes 323090700 (308.1 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 2198497  bytes 395045237 (376.7 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: bond1.521        9000  1910401      0      3 0          7624      0      3      0 BMRU]
[if: bond1.521: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9000]
[if: inet 55.235.37.49  netmask 255.255.224.0  broadcast 55.235.63.255]
[if: inet6 fe80::4600:4dff:fe65:4869  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:65:48:69  txqueuelen 1000  (Ethernet)]
[if: RX packets 1910402  bytes 80236884 (76.5 MiB)]
[if: RX errors 0  dropped 3  overruns 0  frame 0]
[if: TX packets 7624  bytes 339912 (331.9 KiB)]
[if: TX errors 0  dropped 3 overruns 0  carrier 0  collisions 0]
[if: ]
[net: bond2.520        9000   482174      0      0 0           700      0      5      0 BMRU]
[if: bond2.520: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9000]
[if: inet 55.235.67.49  netmask 255.255.240.0  broadcast 55.235.79.255]
[if: inet6 fe80::4600:4dff:fe65:486a  prefixlen 64  scopeid 0x20<link>]
[if: ether 44:00:4d:65:48:6a  txqueuelen 1000  (Ethernet)]
[if: RX packets 482174  bytes 20251308 (19.3 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 700  bytes 48984 (47.8 KiB)]
[if: TX errors 0  dropped 5 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens0             1500 22096100      0      2 0       6925446      0      0      0 BMsRU]
[if: ens0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:a7:a2:0c  txqueuelen 1000  (Ethernet)]
[if: RX packets 22096121  bytes 2102609283 (1.9 GiB)]
[if: RX errors 0  dropped 2  overruns 0  frame 0]
[if: TX packets 6925506  bytes 670102620 (639.0 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens1             1500 21177532      0  84030 0       5149500      0      0      0 BMsRU]
[if: ens1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:a7:a2:0d  txqueuelen 1000  (Ethernet)]
[if: RX packets 21177533  bytes 2059082537 (1.9 GiB)]
[if: RX errors 0  dropped 84030  overruns 0  frame 0]
[if: TX packets 5149500  bytes 315750267 (301.1 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens2             9000  3014003      0      0 0       2427369      0      0      0 BMsRU]
[if: ens2: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 9000]
[if: ether 44:00:4d:65:48:69  txqueuelen 1000  (Ethernet)]
[if: RX packets 3014004  bytes 340052424 (324.2 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 2427370  bytes 300741972 (286.8 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens3             9000  3933696      0      0 0       2427813      0      0      0 BMsRU]
[if: ens3: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 9000]
[if: ether 44:00:4d:65:48:69  txqueuelen 1000  (Ethernet)]
[if: RX packets 3933696  bytes 391555040 (373.4 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 2427813  bytes 300782200 (286.8 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens4             9000  2519503      0      0 0       2424826      0      0      0 BMsRU]
[if: ens4: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 9000]
[if: ether 44:00:4d:65:48:6a  txqueuelen 1000  (Ethernet)]
[if: RX packets 2519503  bytes 312360368 (297.8 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 2424826  bytes 300603046 (286.6 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ens5             9000  2999968      0      0 0       2423428      0      0      0 BMsRU]
[if: ens5: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 9000]
[if: ether 44:00:4d:65:48:6a  txqueuelen 1000  (Ethernet)]
[if: RX packets 2999968  bytes 339266204 (323.5 MiB)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 2423429  bytes 300505196 (286.5 MiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth2             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth2: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:a7:a2:0e  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth3             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth3: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:a7:a2:0f  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth4             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth4: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:65:48:6b  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth5             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth5: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:65:48:6c  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth8             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth8: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:65:48:3b  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: eth9             1500        0      0      0 0             0      0      0      0 BMU]
[if: eth9: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500]
[if: ether 44:00:4d:65:48:3c  txqueuelen 1000  (Ethernet)]
[if: RX packets 0  bytes 0 (0.0 B)]
[if: RX errors 0  dropped 0  overruns 0  frame 0]
[if: TX packets 0  bytes 0 (0.0 B)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: lo              65536 302881169      0   2985 0      302881169      0      0      0 LRU]
[if: lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536]
[if: inet 127.0.0.1  netmask 255.0.0.0]
[if: inet6 ::1  prefixlen 128  scopeid 0x10<host>]
[if: loop  txqueuelen 1000  (Local Loopback)]
[if: RX packets 302881169  bytes 4082730699199 (3.7 TiB)]
[if: RX errors 0  dropped 2985  overruns 0  frame 0]
[if: TX packets 302881169  bytes 4082730699199 (3.7 TiB)]
[if: TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0]
[if: ]
[net: ltp_ns_veth2      552 107227919      0     72 0      57053147      0     43      0 BMRU]
[if: ltp_ns_veth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 552]
[if: inet 10.0.0.2  netmask 255.255.255.0  broadcast 0.0.0.0]
[if: ether aa:31:fd:7c:7f:b1  txqueuelen 1000  (Ethernet)]
[if: RX packets 107227919  bytes 45168157126 (42.0 GiB)]
[if: RX errors 0  dropped 72  overruns 0  frame 0]
[if: TX packets 57053147  bytes 53687217113 (50.0 GiB)]
[if: TX errors 0  dropped 43 overruns 0  carrier 0  collisions 0]
[if: ]
[mount: proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)]
[mount: sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)]
[mount: devtmpfs on /dev type devtmpfs (rw,nosuid,size=4096k,nr_inodes=1048576,mode=755)]
[mount: securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)]
[mount: tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)]
[mount: devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)]
[mount: tmpfs on /run type tmpfs (rw,nosuid,nodev,size=39294844k,nr_inodes=819200,mode=755)]
[mount: tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755)]
[mount: cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)]
[mount: pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)]
[mount: efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)]
[mount: none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)]
[mount: cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)]
[mount: cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)]
[mount: cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)]
[mount: cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)]
[mount: cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)]
[mount: cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)]
[mount: cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)]
[mount: cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)]
[mount: cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)]
[mount: cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)]
[mount: cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)]
[mount: /dev/sda4 on / type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,sunit=512,swidth=512,noquota)]
[mount: systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=19596)]
[mount: hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)]
[mount: mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)]
[mount: debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)]
[mount: tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)]
[mount: tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=98237104k,nr_inodes=1048576)]
[mount: fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)]
[mount: configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)]
[mount: ramfs on /run/credentials/systemd-sysusers.service type ramfs (ro,nosuid,nodev,noexec,relatime,mode=700)]
[mount: /dev/sda5 on /var type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,sunit=512,swidth=512,noquota)]
[mount: /dev/sda3 on /boot type ext2 (rw,relatime,stripe=64)]
[mount: /dev/sda2 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)]
[mount: sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)]
[mount: binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)]
[mount: tracefs on /sys/kernel/debug/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)]
[mount: tmpfs on /run/netns type tmpfs (rw,nosuid,nodev,size=39294844k,nr_inodes=819200,mode=755)]
[mount: cgroup2 on /tmp/ltp-kdfmLs9sNa/cgroup_unified type cgroup2 (rw,relatime,memory_recursiveprot)]
[mount: nsfs on /run/netns/tst_net_ns0 type nsfs (rw)]
[mount: nsfs on /run/netns/tst_net_ns0 type nsfs (rw)]
[mount: nsfs on /run/netns/tst_net_ns1 type nsfs (rw)]
[mount: nsfs on /run/netns/tst_net_ns1 type nsfs (rw)]
[mount: /dev/sdb1 on /fs/sdb1 type ext4 (rw,relatime,stripe=64)]
[mount: nfsd on /proc/fs/nfsd type nfsd (rw,relatime)]
Fri May 19 03:17:29 PM CST 2023
Latency measurements
File /usr/tmp/lmbench/XXX write bandwidth: 1337511 KB/sec
Fri May 19 03:17:30 PM CST 2023
Calculating file system latency
"File system latency
0k	439	78365	93876
1k	307	53690	84045
4k	314	55605	66696
10k	277	40133	72167

Fri May 19 03:17:32 PM CST 2023
Local networking
Fri May 19 03:17:35 PM CST 2023
Bandwidth measurements

"read bandwidth
0.000512 715.30
0.001024 1368.44
0.002048 2435.24
0.004096 3900.39
0.008192 5491.16
0.016384 6692.98
0.032768 7214.43
0.065536 7390.03
0.131072 7459.19
0.262144 7253.94
0.524288 6483.28
1.05 5971.60
2.10 5873.35
4.19 5818.35
8.39 5365.28
16.78 4432.55
33.55 4168.77
67.11 3865.72
134.22 3958.06
268.44 4058.29
536.87 4194.40
1073.74 4304.89

"read open2close bandwidth
0.000512 196.34
0.001024 389.45
0.002048 771.42
0.004096 1448.43
0.008192 2404.43
0.016384 3735.17
0.032768 5010.60
0.065536 6017.28
0.131072 6635.04
0.262144 6670.33
0.524288 6179.28
1.05 5825.42
2.10 5803.26
4.19 5766.36
8.39 5337.11
16.78 4439.59
33.55 4186.45
67.11 3865.72
134.22 3953.63
268.44 4062.53
536.87 4194.60
1073.74 4305.94

Fri May 19 03:17:51 PM CST 2023

[Fri May 19 03:17:51 PM CST 2023]
  • 利用正则表达式对上面的测试结果进行处理,代码片段如下
#rtfile:lmbench测试结果文件
#case:lmbench的测试项,对应benchmark
...
with open(rtfile, 'r') as f:
            lines = "".join(f.readlines())
        regex = r"\n([\w\W]*?)\n\n"
        if 'file' in case:
            file_latency = re.compile(f"File system latency{regex}").findall(lines)[-1].split('\n')
            data.setdefault(case,{})['file_create_0k'] = format(1000 / int(file_latency[0].split('\t')[2]) * 1000, '.4f')
            data.setdefault(case,{})['file_delete_0k'] = format(1000 / int(file_latency[0].split('\t')[3]) * 1000, '.4f')
            data.setdefault(case,{})['file_create_10k'] = format(10 * 1000 / int(file_latency[-1].split('\t')[2]) * 1000, '.4f')
            data.setdefault(case,{})['file_delete_10k'] = format(10 * 1000 / int(file_latency[-1].split('\t')[3]) * 1000, '.4f')
            data.setdefault(case,{})['read_bandwidth'] = re.compile(f"read bandwidth{regex}").findall(lines)[-1].split('\n')[-1].split()[-1]
            data.setdefault(case,{})['read_open2close_bandwidth'] = re.compile(f"read open2close bandwidth{regex}").findall(lines)[-1].split('\n')[-1].split()[-1]
...

 

文章来自个人专栏
Ctyunos
2 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0