您的位置:首页 > 运维架构 > Linux

linux系统IO性能测试

2018-12-10 18:57 381 查看

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时间。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  dd linux time