LMbench 实用的微观性能分析工具

我们在做高性能服务的时候,通常需要避免7宗罪,比如说内存拷贝,昂贵的系统调用等等。 但是这些罪的代价是多少,我们并不清楚。 在设计的时候,我们会需要根据数据去做方案的取舍。但是这些测量数据哪里来呢? google大神是个很好的地方,但是有很多缺点,首先你需要的知识是分散的,第二你需要的知识是二手的。 这时候LMbench来救助了。

LMbench – Tools for Performance Analysis
官方网站: http://www.bitmover.com/lmbench/

What is LMbench?
* Suite of simple, portable benchmarks
* Compares different systems performance
* Results available for most major vendors (SUN, HP, IBM, DEC, SGI, PCs including 200 Mhz P6’s)
* Free software, covered by the GNU General Public License.

* Bandwidth benchmarks
o Cached file read
o Memory copy (bcopy)
o Memory read
o Memory write
o Pipe
o TCP
* Latency benchmarks
o Context switching.
o Networking: connection establishment, pipe, TCP, UDP, and RPC hot potato
o File system creates and deletes.
o Process creation.
o Signal handling
o System call overhead
o Memory read latency
* Miscellanious
o Processor clock rate calculation

可以看出,他主要测量2个方面的东西: 带宽和延时, 涉及到系统组成的很底层。不多说了,我们在ubuntu下实践下:

# apt-get build-dep lmbench
# apt-get source lmbench
# cd lmbench-3.0-a9/
# tar xzvf lmbench-3.0-a9.tgz 
# cd lmbench-3.0-a9
# make  #如果不错意外的话,编译顺利完成

我们这时候可以看到bin目录有很多的工具程序,用于测量系统的方方面面. 这些工具可以单独使用, 在doc目录的文档里面又每个工具的原理和设计思想以及如何使用.

#make results

这时候会问你很多问题, 回车默认就好, 当问到文件的临时目录时,请确保你的目录又足够的空间,否则会失败; 问到mail测试结果的时候选择NO.不出意外的话,系统开始干活, 测量的结果保存在results目录里面.

还想再运行的话:

#make rerun

看测试的summary的话:

#make see

在results目录下生成了个summary.out的文本文件.

我摘录了点:
Lmbench说内存操作还是很慢:
Local Communication bandwidths in MB/s – bigger is better
—————————————————————————–
Host OS Pipe AF TCP File Mmap Bcopy Bcopy Mem Mem
UNIX reread reread (libc) (hand) read write
——— ————- —- —- —- —— —— —— —— —- —–
my174.cm4 Linux 2.6.18- 1282 2672 2707 3879.2 6664.8 2778.0 3014.8 4559 4408.

上下文切换也要命:
Context switching – times in microseconds – smaller is better
————————————————————————-
Host OS 2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16p/64K
ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw
——— ————- —— —— —— —— —— ——- ——-
my174.cm4 Linux 2.6.18- 6.1100 7.0200 6.1100 8.7400 7.7200 8.96000 9.62000

系统调用快了很多,但是还是慢:
Processor, Processes – times in microseconds – smaller is better
——————————————————————————
Host OS Mhz null null open slct sig sig fork exec sh
call I/O stat clos TCP inst hndl proc proc proc
——— ————- —- —- —- —- —- —- —- —- —- —- —-
my174.cm4 Linux 2.6.18- 1593 0.09 0.16 1.01 1.64 5.48 0.20 1.86 184. 702. 2334

数学计算就是快:
Basic integer operations – times in nanoseconds – smaller is better
——————————————————————-
Host OS intgr intgr intgr intgr intgr
bit add mul div mod
——— ————- —— —— —— —— ——
my174.cm4 Linux 2.6.18- 0.6300 0.3100 0.2200 15.1 14.4

点击查看我的机器的测试结果

玩的开心. 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值