linux测试nvme性能,使用Python测试NVMe吞吐量

目前我需要做一些吞吐量测试。我的硬件设置是,我有一个三星950 Pro连接到一个NVMe控制器,该控制器通过PCIe端口连接到主板。我有一个linuxnvme设备,它与我在文件系统上安装的设备相对应。在

我希望使用Python来实现这一点。我计划在安装SSD的文件系统上打开一个文件,记录时间,向文件写入一些n长度的字节流,记录时间,然后使用os模块文件操作实用程序关闭文件。这里有一个用于测量写吞吐量的函数。在def perform_timed_write(num_bytes, blocksize, fd):

"""

This function writes to file and records the time

The function has three steps. The first is to write, the second is to

record time, and the third is to calculate the rate.

Parameters

----------

num_bytes: int

blocksize that needs to be written to the file

fd: string

location on filesystem to write to

Returns

-------

bytes_per_second: float

rate of transfer

"""

# generate random string

random_byte_string = os.urandom(blocksize)

# open the file

write_file = os.open(fd, os.O_CREAT | os.O_WRONLY | os.O_NONBLOCK)

# set time, write, record time

bytes_written = 0

before_write = time.clock()

while bytes_written < num_bytes:

os.write(write_file, random_byte_string)

bytes_written += blocksize

after_write = time.clock()

#close the file

os.close(write_file)

# calculate elapsed time

elapsed_time = after_write - before_write

# calculate bytes per second

bytes_per_second = num_bytes / elapsed_time

return bytes_per_second

在/fsmnt/fs1安装SSD之后,我使用这个jobfile来测试吞吐量

^{pr2}$

我注意到Python函数返回的写入速度明显高于fio。因为Python是如此高的级别,所以您会放弃很多控制。我想知道Python是否在做一些事情来欺骗它的速度。有人知道为什么Python生成的写入速度会比fio生成的高出很多吗?在

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值