1.概述
lmbench是个用于评价系统综合性能的多平台开源benchmark,能够测试包括文档读写、内存操作、进程创建销毁开销、网络等性能,测试 方法简单。
Lmbench是个多平台软件,因此能够对同级别的系统进行比较测试,反映不同系统的优劣势,通过选择不同的库函数我们就能够比较库函数的性能;更为重要的是,作为一个开源软件, lmbench提供一个测试框架,假如测试者对测试项目有更高的测试需要,能够通过少量的修改源代码达到目的。
2.安装配置lmbench
从官网下载http://www.bitmover.com/lmbench/get_lmbench.html lmbench3并且解压。
szp@szp-pc:~/lmbench3$ ls -l 总用量 76 -r--r--r-- 1 szp szp 1779 8月 23 2005 ACKNOWLEDGEMENTS drwxrwxr-x 4 szp szp 4096 4月 26 16:17 bin -r--r--r-- 1 szp szp 3695 8月 23 2005 CHANGES -r--r--r-- 1 szp szp 17982 8月 23 2005 COPYING -r--r--r-- 1 szp szp 5728 8月 23 2005 COPYING-2 drwxrwxr-x 2 szp szp 4096 8月 23 2005 doc -r--r--r-- 1 szp szp 9935 8月 23 2005 hbench-REBUTTAL -r--r--r-- 1 szp szp 1607 8月 23 2005 Makefile -r--r--r-- 1 szp szp 561 8月 23 2005 README drwxrwxr-x 2 szp szp 4096 8月 23 2005 results drwxrwxr-x 2 szp szp 4096 8月 23 2005 scripts drwxrwxr-x 2 szp szp 4096 4月 26 16:23 src szp@szp-pc:~/lmbench3$
进入目录下的src文件夹,执行make 命令。
szp@szp-pc:~/lmbench3/src$ make results make[1]: 进入目录“/home/szp/lmbench3/src” gcc -O -DRUSAGE -DHAVE_uint=1 -DHAVE_int64_t=1 -DHAVE_DRAND48 -DHAVE_SCHED_SETAFFINITY=1 -o ../bin/x86_64-linux-gnu/disk disk.c ../bin/x86_64-linux-gnu/lmbench.a -lm /usr/bin/ld: /tmp/cc3ZbIZp.o: in function `seekto': disk.c:(.text+0x37): undefined reference to `llseek' collect2: error: ld returned 1 exit status make[1]: *** [Makefile:323:../bin/x86_64-linux-gnu/disk] 错误 1 make[1]: 离开目录“/home/szp/lmbench3/src” make: *** [Makefile:114:lmbench] 错误 2
出现错误,在disk.c程序中找不到llseek,原因是llseek接口函数在GCC 7.3.0编译器中被lseek64替代。将测试工具的disk.c源码文件中的llseek接口函数全部替换成lseek64,重新编译。接下来lmbench会让用户配置测试文件。可以选择缺省值,详细解释如下。
如果编译没有错误,就会出现一些选择提示以对测试进行一个配置并生成配置脚本,首先出现的如下:
If you are running on an MP machine and you want to try running
multiple copies of lmbench in parallel, you can specify how many here.
Using this option will make the benchmark run 100x slower (sorry).
NOTE: WARNING! This feature is experimental and many results are
known to be incorrect or random!
MULTIPLE COPIES [default 1]
提示你同时运行多少个并行的测试,对应为结果中的 scal load 项
接下来是选择作业调度控制方法,选 1 允许调度作业即可。如下:
Options to control job placement
1) Allow scheduler to place jobs
2) Assign each benchmark process with any attendent child processes
to its own processor
3) Assign each benchmark process with any attendent child processes
to its own processor, except that it will be as far as possible
from other processes
4) Assign each benchmark and attendent processes to their own
processors
5) Assign each benchmark and attendent processes to their own
processors, except that they will be as far as possible from
each other and other processes
6) Custom placement: you assign each benchmark process with attendent
child processes to processors
7) Custom placement: you assign each benchmark and attendent
processes to processors
Note: some benchmarks, such as bw_pipe, create attendent child
processes for each benchmark process. For example, bw_pipe
needs a second process to send data down the pipe to be read
by the benchmark process. If you have three copies of the
benchmark process running, then you actually have six processes;
three attendent child processes sending data down the pipes and
three benchmark processes reading data and doing the measurements.
Job placement selection: 1
接下来是指定内存,本次指定为 512M,如下。
Several benchmarks operate on a range of memory. This memory should be
sized such that it is at least 4 times as big as the external cache[s]
on your system. It should be no more than 80% of your physical memory.
The bigger the range, the more accurate the results, but larger sizes
take somewhat longer to run the benchmark.
MB [default 2814]
512
选择运行的子集,默认为全部,本次使用默认值,如下。
lmbench measures a wide variety of system performance, and the full suite
of benchmarks can take a long time on some platforms. Consequently, we
offer the capability to run only predefined subsets of benchmarks, one
for operating system specific benchmarks and one for hardware specific
benchmarks. We also offer the option of running only selected benchmarks
which is useful during operating system development.
Please remember that if you intend to publish the results you either need
to do a full run or one of the predefined OS or hardware subsets.
SUBSET (ALL|HARWARE|OS|DEVELOPMENT) [default all]
然后测试开始,需要等待一些时间。
Confguration done, thanks.
There is a mailing list for discussing lmbench hosted at BitMover.
Send mail to majordomo@bitmover.com to join the list.
Using config in CONFIG.user3-VT3456-8614CMB
Latency measurements
Calculating file system latency
Local networking
Bandwidth measurements
3.查看测试结果
执行make see命令可以查看测试结果。
szp@szp-pc:~/lmbench3$ make see cd results && make summary percent 2>/dev/null | more make[1]: 进入目录“/home/szp/lmbench3/results” L M B E N C H 3 . 0 S U M M A R Y ------------------------------------ (Alpha software, do not distribute) Basic system parameters ------------------------------------------------------------------------------ Host OS Description Mhz tlb cache mem scal pages line par load bytes --------- ------------- ----------------------- ---- ----- ----- ------ ---- szp-pc Linux 5.8.0-4 x86_64-linux-gnu 64 1 Basic integer operations - times in nanoseconds - smaller is better ------------------------------------------------------------------- Host OS intgr intgr intgr intgr intgr bit add mul div mod --------- ------------- ------ ------ ------ ------ ------ szp-pc Linux 5.8.0-4 0.2200 0.9300 6.1200 4.3200 Basic float operations - times in nanoseconds - smaller is better ----------------------------------------------------------------- Host OS float float float float add mul div bogo --------- ------------- ------ ------ ------ ------ szp-pc Linux 5.8.0-4 0.9300 0.9300 3.2000 1.2000 Basic double operations - times in nanoseconds - smaller is better ------------------------------------------------------------------ Host OS double double double double add mul div bogo --------- ------------- ------ ------ ------ ------ szp-pc Linux 5.8.0-4 0.9300 1.2300 4.0600 1.3800 Memory latencies in nanoseconds - smaller is better (WARNING - may not be correct, check graphs) ------------------------------------------------------------------------------ Host OS Mhz L1 $ L2 $ Main mem Rand mem Guesses --------- ------------- --- ---- ---- -------- -------- ------- user2-VT3 Linux 3.8.0-c 1598 2.5060 12.5 56.5 143.7 make[1]: 离开目录“/home/szp/lmbench3/results”
主要参数说明:
Memory latencies(内存操作延时)
L1:L1 缓存操作延时
L2:L2 缓存操作延时
Main Mem:系统内存连续操作延时
Rand Mem:系统内存随机访问操作延时
如果想继续使用上次配置的结果,使用make rerun命令。
此外,lmbench测试程序运行的时间较长,需要耐心等待。