当前位置: 首页 > article >正文

Ubuntu 下测试 NVME SSD 的读写速度

在 Ubuntu 系统下,测试 NVME SSD 的读写速度,有好多种方法,常用的有如下几种:

1. Gnome-disks

Gnome-disks(也称为“Disks”)是 GNOME 桌面环境中的磁盘管理工具,有图形界面,是测试 NVME SSD 读写速度操作最方便的一种。

可以通过以下方式安装:

    sudo apt update
    sudo apt install gnome-disk-utility

安装完成后,从 Settings 选择 Disks,打开该应用。

也可以在 Run Programm 下键入 gnomes-disks 直接运行:

在左侧的设备列表中选择你的固态硬盘,然后点击右上角的菜单图标(三个竖点),选择 "Benchmark Disk" 来进行速度测试。 

下面是一个 128GB SSD 的测试结果:

作为对比,这是 一张 64GB SD 卡的结果,看起来性能比较差:

另一张 SD 卡:

2. hdparm

当然,也可以使用 hdparm 来测试去读取速度:

        sudo apt-get install hdparm

        sudo hdparm -Tt /dev/mmcblk0

/dev/mmcblk0:
 Timing cached reads:   9082 MB in  2.00 seconds = 4546.07 MB/sec
 HDIO_DRIVE_CMD(identify) failed: Invalid argument
 Timing buffered disk reads:  36 MB in  3.11 seconds =  11.57 MB/sec

        sudo hdparm -Tt /dev/nvme0n1

/dev/nvme0n1:
 Timing cached reads:   9754 MB in  2.00 seconds = 4882.31 MB/sec
 HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device
 Timing buffered disk reads: 1056 MB in  3.00 seconds = 351.64 MB/sec

3. fio

fio 是一个功能强大的磁盘性能测试工具,可以执行各种读取和写入测试,并提供详细的性能报告。

可以使用以下命令安装 fio:

        sudo apt update    
        sudo apt install fio

安装完成后,创建一个配置文件,例如:test_ssd.fio,并在其中定义测试的参数。

    [global]
    ioengine=libaio
    direct=1
    runtime=60
    time_based
    bs=4k
    numjobs=1
    size=1G

    [test_ssd_read]
    filename=/dev/nvme0n1
    rw=read

    [test_ssd_write]
    filename=/dev/nvme0n1
    rw=write

    [test_ssd_randrw]
    filename=/dev/nvme0n1
    rw=randrw

然后,在终端中运行以下命令来执行测试:

        sudo fio test_ssd.fio

test_ssd_read: (g=0): rw=read, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1
test_ssd_write: (g=0): rw=write, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1
test_ssd_randrw: (g=0): rw=randrw, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1
fio-3.16
Starting 3 processes
Jobs: 3 (f=3): [R(1),W(1),m(1)][100.0%][r=40.2MiB/s,w=81.1MiB/s][r=10.3k,w=20.8k IOPS][eta 00m:00s]
test_ssd_read: (groupid=0, jobs=1): err= 0: pid=11250: Mon Jan  6 13:43:18 2025
  read: IOPS=6125, BW=23.9MiB/s (25.1MB/s)(1436MiB/60001msec)
    slat (usec): min=3, max=7732, avg=14.71, stdev=30.46
    clat (nsec): min=1750, max=23628k, avg=144762.35, stdev=177571.14
     lat (usec): min=37, max=23643, avg=160.05, stdev=180.14
    clat percentiles (usec):
     |  1.00th=[   52],  5.00th=[   55], 10.00th=[   66], 20.00th=[   73],
     | 30.00th=[   79], 40.00th=[  104], 50.00th=[  125], 60.00th=[  141],
     | 70.00th=[  163], 80.00th=[  192], 90.00th=[  262], 95.00th=[  306],
     | 99.00th=[  367], 99.50th=[  392], 99.90th=[ 3458], 99.95th=[ 3720],
     | 99.99th=[ 5866]
   bw (  KiB/s): min=22280, max=25600, per=58.79%, avg=24492.71, stdev=542.05, samples=119
   iops        : min= 5570, max= 6400, avg=6123.14, stdev=135.51, samples=119
  lat (usec)   : 2=0.01%, 4=0.01%, 10=0.01%, 20=0.01%, 50=0.19%
  lat (usec)   : 100=38.84%, 250=49.97%, 500=10.75%, 750=0.04%, 1000=0.02%
  lat (msec)   : 2=0.04%, 4=0.11%, 10=0.02%, 20=0.01%, 50=0.01%
  cpu          : usr=5.19%, sys=16.83%, ctx=367841, majf=0, minf=18
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=367511,0,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=1
test_ssd_write: (groupid=0, jobs=1): err= 0: pid=11251: Mon Jan  6 13:43:18 2025
  write: IOPS=16.3k, BW=63.7MiB/s (66.8MB/s)(3820MiB/60001msec); 0 zone resets
    slat (usec): min=3, max=1150, avg=13.95, stdev= 2.73
    clat (nsec): min=1167, max=3738.0k, avg=43920.67, stdev=12785.94
     lat (usec): min=28, max=3742, avg=58.42, stdev=13.36
    clat percentiles (usec):
     |  1.00th=[   41],  5.00th=[   41], 10.00th=[   42], 20.00th=[   42],
     | 30.00th=[   42], 40.00th=[   43], 50.00th=[   43], 60.00th=[   43],
     | 70.00th=[   44], 80.00th=[   46], 90.00th=[   48], 95.00th=[   51],
     | 99.00th=[   60], 99.50th=[   65], 99.90th=[  114], 99.95th=[  174],
     | 99.99th=[  326]
   bw (  KiB/s): min=62512, max=69112, per=79.17%, avg=65189.33, stdev=725.54, samples=119
   iops        : min=15628, max=17278, avg=16297.32, stdev=181.38, samples=119
  lat (usec)   : 2=0.01%, 4=0.01%, 10=0.01%, 20=0.01%, 50=93.90%
  lat (usec)   : 100=5.97%, 250=0.10%, 500=0.01%, 750=0.01%, 1000=0.01%
  lat (msec)   : 2=0.01%, 4=0.01%
  cpu          : usr=13.82%, sys=39.91%, ctx=977956, majf=0, minf=13
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=0,978007,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=1
test_ssd_randrw: (groupid=0, jobs=1): err= 0: pid=11252: Mon Jan  6 13:43:18 2025
  read: IOPS=4290, BW=16.8MiB/s (17.6MB/s)(1006MiB/60001msec)
    slat (usec): min=3, max=4648, avg=14.43, stdev=20.50
    clat (usec): min=2, max=8482, avg=142.87, stdev=154.52
     lat (usec): min=29, max=8497, avg=157.87, stdev=156.10
    clat percentiles (usec):
     |  1.00th=[   46],  5.00th=[   50], 10.00th=[   70], 20.00th=[   73],
     | 30.00th=[   77], 40.00th=[   89], 50.00th=[  116], 60.00th=[  137],
     | 70.00th=[  161], 80.00th=[  200], 90.00th=[  265], 95.00th=[  318],
     | 99.00th=[  383], 99.50th=[  408], 99.90th=[ 3163], 99.95th=[ 3654],
     | 99.99th=[ 4146]
   bw (  KiB/s): min=15536, max=21768, per=41.20%, avg=17163.20, stdev=1419.46, samples=119
   iops        : min= 3884, max= 5442, avg=4290.76, stdev=354.88, samples=119
  write: IOPS=4286, BW=16.7MiB/s (17.6MB/s)(1005MiB/60001msec); 0 zone resets
    slat (usec): min=3, max=8166, avg=15.19, stdev=26.92
    clat (usec): min=2, max=10019, avg=51.45, stdev=52.63
     lat (usec): min=28, max=10041, avg=67.20, stdev=59.35
    clat percentiles (usec):
     |  1.00th=[   41],  5.00th=[   42], 10.00th=[   42], 20.00th=[   42],
     | 30.00th=[   43], 40.00th=[   43], 50.00th=[   43], 60.00th=[   44],
     | 70.00th=[   47], 80.00th=[   50], 90.00th=[   75], 95.00th=[  104],
     | 99.00th=[  113], 99.50th=[  130], 99.90th=[  215], 99.95th=[  314],
     | 99.99th=[ 2540]
   bw (  KiB/s): min=15312, max=21620, per=20.81%, avg=17139.04, stdev=1449.15, samples=119
   iops        : min= 3828, max= 5405, avg=4284.72, stdev=362.32, samples=119
  lat (usec)   : 4=0.02%, 10=0.01%, 20=0.01%, 50=42.73%, 100=24.79%
  lat (usec)   : 250=26.79%, 500=5.53%, 750=0.02%, 1000=0.01%
  lat (msec)   : 2=0.02%, 4=0.07%, 10=0.01%, 20=0.01%
  cpu          : usr=7.95%, sys=23.05%, ctx=514776, majf=0, minf=20
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=257454,257191,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=1

Run status group 0 (all jobs):
   READ: bw=40.7MiB/s (42.7MB/s), 16.8MiB/s-23.9MiB/s (17.6MB/s-25.1MB/s), io=2441MiB (2560MB), run=60001-60001msec
  WRITE: bw=80.4MiB/s (84.3MB/s), 16.7MiB/s-63.7MiB/s (17.6MB/s-66.8MB/s), io=4825MiB (5059MB), run=60001-60001msec

Disk stats (read/write):
  nvme0n1: ios=624031/1233179, merge=0/0, ticks=84957/51088, in_queue=136046, util=100.00%

将 numjobs参数改为:8,最后结果如下:

Run status group 0 (all jobs):
   READ: bw=177MiB/s (186MB/s), 8521KiB/s-13.6MiB/s (8726kB/s-14.2MB/s), io=10.4GiB (11.1GB), run=60001-60006msec
  WRITE: bw=280MiB/s (294MB/s), 8509KiB/s-27.0MiB/s (8713kB/s-29.3MB/s), io=16.4GiB (17.6GB), run=60001-60006msec

Disk stats (read/write):
  nvme0n1: ios=2713427/4292312, merge=0/0, ticks=702077/462120, in_queue=1164198, util=100.00%

可见,设置不同的参数,测得的结果也大不相同,参数灵活,使用复杂。

                                                                老徐,2025/01/06


http://www.kler.cn/a/472398.html

相关文章:

  • Profinet转EtherNet/IP网关连接AB PLC的应用案例
  • spring mvc源码学习笔记之九
  • n 维数组(张量)关于轴 axis 的理解
  • 【和春笋一起学C++】文本输入与读取(二)
  • Java语言的语法
  • 【Go学习】-02-1-标准库:fmt、os、time
  • 吾杯网络安全技能大赛——Misc方向WP
  • 25上软考中级【软件评测师】易混淆知识点
  • flutter索引知识点
  • 7.什么是java内部类?有什么作用?
  • sqlalchemy查看已经创建的索引
  • ArcGis通过TIFF文件生成渔网
  • whowantstobeking靶机
  • Docker: 现代开发的利器,从入门到实践
  • Java全套面试题整理,含答案(2025最新)
  • Python中的基本交易算法
  • API调用淘宝京东商品详情接口示例参考,json格式数据示例
  • [读书日志]从零开始学习Chisel 第五篇:Scala面向对象编程——类继承(敏捷硬件开发语言Chisel与数字系统设计)
  • js es6 reduce函数, 通过规格生成sku
  • 【C语言】_指针与数组
  • Matlab回归预测大合集(不定期更新)-188
  • node.js内置模块之---buffer 模块
  • PixPin—— 高效截图工具的下载与使用攻略
  • 如何安全保存用户密码及哈希算法
  • 浅尝Appium自动化框架
  • 计算机网络 (30)多协议标签交换MPLS