码迷,mamicode.com
首页 > 系统相关 > 详细

linux系统IO性能测试

时间:2018-12-11 00:40:12      阅读:328      评论:0      收藏:0      [点我收藏+]

标签:程序   多次   linu   缓存   时间   code   null   磁盘   cache   

dd命令能粗略测试硬盘IO性能,但是执行dd命令测试硬盘IO性能,对硬盘的损害很大,不建议多次或长时间尝试.

[root@localhost /]# time dd if=/dev/zero of=/dev/null bs=4k count=256000
256000+0 records in
256000+0 records out
1048576000 bytes (1.0 GB) copied, 0.782804 s, 1.3 GB/s

real    0m0.786s
user    0m0.160s
sys 0m0.626s
[root@localhost /]# time dd if=/dev/zero of=/dev/null bs=4k count=256000 oflag=dsync
256000+0 records in
256000+0 records out
1048576000 bytes (1.0 GB) copied, 0.758887 s, 1.4 GB/s

real    0m0.762s
user    0m0.120s
sys 0m0.642s
[root@localhost /]# time dd if=/dev/zero of=/dev/null bs=4k count=256000 conv=fdatasync
dd: fsync failed for ‘/dev/null’: Invalid argument
256000+0 records in
256000+0 records out
1048576000 bytes (1.0 GB) copied, 0.514259 s, 2.0 GB/s

real    0m0.518s
user    0m0.128s
sys 0m0.390s
[root@localhost /]# 

oflag=dsync:dd会从/dev/zero中,每次读取4Kbytes数据,然后直接写入到硬盘当中,重复此步骤,直到共读取并且写入了1 Gbytes的数据。这个过程可能会很慢,因为没有用到写缓存(write cache),加此参数,可以模拟数据库的插入操作,可能跟接近真实。

conv=fdatasync:dd会从/dev/zero中一次性读取1 Gbytes的数据,写入到磁盘的缓存中,然后再从磁盘缓存中读取,一次性写入到硬盘当中。

time命令用来计算dd程序的运行耗时(real), 用户态cpu耗时(user), 系统态cpu耗时(sys)。
real : 表示foo程序整个的运行耗时。可以理解为foo运行开始时刻你看了一下手表,foo运行结束时,你又看了一下手表,两次时间的差值就是本次real 代表的值
user:这个时间代表的是foo运行在用户态的cpu时间,
sys: 这个时间代表的是foo运行在核心态的cpu时间。

linux系统IO性能测试

标签:程序   多次   linu   缓存   时间   code   null   磁盘   cache   

原文地址:http://blog.51cto.com/ityunwei2017/2328576

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!