python 下载图片 写硬盘 慢_如何在Python中获得读/写磁盘速度?

在Python程序中,我需要获得主机上所有磁盘的累计读/写速度.我使用subprocess.check_output()来调用以下Linux shell命令:

$sudo hdparm -t /dev/sda

这给出了结果:

/dev/sda:

Timing buffered disk reads: 1488 MB in 3.00 seconds = 495.55 MB/sec

然后我可以解析495.55.好的,到目前为止一切顺利.

但是在hdparm的手册页上我找到了-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.

问题是:

如何在执行测量时确保没有其他进程同时访问磁盘?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值