我已经看到了使用dd对这样的硬盘进行基准测试的命令:
$time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"
有没有比这更好的方法呢?
解决方法:
我通常使用hdparm来对我的HDD进行基准测试.您可以对直接读取和缓存读取进行基准测试.您需要多次运行命令以建立平均值.
例子
这是直接阅读.
$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++.
参考
> How to use ‘dd’ to benchmark your disk or CPU?
> Benchmark disk IO with DD and Bonnie++