[Linux] 使用 dd 指令測試 disk IO 效能


Posted by zoelin2022 on 2022-07-24

參考 https://code.yidas.com/linux-dd-command-test-io/

Read 測試

因為/dev/sda2是一個物理分割槽,對它的讀取會產生IO,/dev/null是偽裝置,相當於黑洞,of到該裝置不會產生IO,所以,這個命令的IO只發生在/dev/sdb1上,也相當於測試磁碟的讀能力。

time dd if=/dev/sda2 of=/dev/null bs=8k count=8388608 ; rm -f /dev/null
229376+0 records in
229376+0 records out
1879048192 bytes (1.9 GB, 1.8 GiB) copied, 5.66444 s, 332 MB/s

real        0m5.666s
user        0m0.287s
sys        0m1.446s

Write 測試

因為/dev/zero是一個偽裝置,它只產生空字元流,對它不會產生IO,所以,IO都會集中在of檔案中,of檔案只用於寫,所以這個命令相當於測試磁碟的寫能力。

time dd if=/dev/zero of=/tmp/output bs=8k count=100000 ; rm -f /tmp/output

使用/dev/zero當來源自定讀取量,Block Size(bs)跟次數(count)相乘等於實際檔案大小。

Block Size設定過大會造成記憶體不足,可以利用count乘數拆分計算總大小。

100000+0 records in
100000+0 records out
819200000 bytes (819 MB, 781 MiB) copied, 1.10363 s, 742 MB/s

real        0m1.106s
user        0m0.084s
sys        0m0.746s

Read & Write 測試

time dd if=/dev/sda2 of=/tmp/output bs=8k count=500000
229376+0 records in
229376+0 records out
1879048192 bytes (1.9 GB, 1.8 GiB) copied, 4.71189 s, 399 MB/s

real        0m4.725s
user        0m0.237s
sys        0m2.736s

#linux







Related Posts

認識JavaScript中的Hoisting

認識JavaScript中的Hoisting

[ Note ] Git 交作業

[ Note ] Git 交作業

遍歷物件 for in 和 for of

遍歷物件 for in 和 for of


Comments