linux系统IO性能测试

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的数据,写入到磁盘的缓存中,而后再从磁盘缓存中读取,一次性写入到硬盘当中。async

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

相关文章
相关标签/搜索