Linux

如何對我的 HDD 進行基準測試?

  • December 14, 2020

我已經看到使用以下命令對一個人的 HDD 進行基準測試dd

$ time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"

還有比這更好的方法嗎?

我通常用來hdparm對我的硬碟進行基準測試。您可以對直接讀取和記憶體讀取進行基準測試。您需要多次執行這些命令來建立一個平均值。

例子

這裡是直接閱讀。

$ sudo hdparm -t /dev/sda2

/dev/sda2:
Timing buffered disk reads: 302 MB in  3.00 seconds = 100.58 MB/sec

這是一個記憶體讀取。

$ sudo hdparm -T /dev/sda2

/dev/sda2:
Timing cached reads:   4636 MB in  2.00 seconds = 2318.89 MB/sec

細節

-t     Perform  timings  of  device reads for benchmark and comparison 
      purposes.  For meaningful results, this operation should be repeated
      2-3 times on an otherwise inactive system (no other active processes) 
      with at least a couple of megabytes of free memory.  This displays  
      the  speed of reading through the buffer cache to the disk without 
      any prior caching of data.  This measurement is an indication of how 
      fast the drive can sustain sequential data reads under Linux, without 
      any filesystem overhead.  To ensure accurate  measurements, the 
      buffer cache is flushed during the processing of -t using the 
      BLKFLSBUF ioctl.

-T     Perform timings of cache reads for benchmark and comparison purposes.
      For meaningful results, this operation should be repeated 2-3
      times on an otherwise inactive system (no other active processes) 
      with at least a couple of megabytes of free memory.  This displays
      the speed of reading directly from the Linux buffer cache without 
      disk access.  This measurement is essentially an indication of the
      throughput of the processor, cache, and memory of the system under 
      test.

使用 dd

我也使用dd過這種類型的測試。我將對上述命令進行的一項修改是將此位添加到命令的末尾,; rm ddfile.

$ time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"; rm ddfile

這將ddfile在命令完成後刪除。注意: ddfile是您不需要保留的臨時文件,它dd是寫入 ( of=ddfile) 的文件,當它使您的 HDD 處於負載狀態時。

超越

如果您需要對硬碟進行更嚴格的測試,您可以使用Bonnie++

參考

引用自:https://unix.stackexchange.com/questions/108838