块设备IO情况查询

Block layer statistics in /sys/block/<dev>/stat


Name            units         description
----            -----         -----------
read I/Os       requests      number of read I/Os processed
read merges     requests      number of read I/Os merged with in-queue I/O
read sectors    sectors       number of sectors read
read ticks      milliseconds  total wait time for read requests
write I/Os      requests      number of write I/Os processed
write merges    requests      number of write I/Os merged with in-queue I/O
write sectors   sectors       number of sectors written
write ticks     milliseconds  total wait time for write requests
in_flight       requests      number of I/Os currently in flight
io_ticks        milliseconds  total time this block device has been active
time_in_queue   milliseconds  total wait time for all requests
discard I/Os    requests      number of discard I/Os processed
discard merges  requests      number of discard I/Os merged with in-queue I/O
discard sectors sectors       number of sectors discarded
discard ticks   milliseconds  total wait time for discard requests

转载于:https://my.oschina.net/redhands/blog/3008574

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您的问题不够清晰,我不确定您想了解什么。如果您是想了解 Linux IO 性能测试以及使用 gettimeofday 和 read 函数进行测试的方法,我可以简单地介绍一下。 Linux IO 性能测试通常使用工具例如 dd、hdparm、fioiozone 等。其中,dd 和 hdparm 是最常用的工具之一。使用 gettimeofday 函数可以获取当前时间,用于计算 IO 操作的时间。使用 read 函数可以读取文件或设备的数据。 以下是一个示例程序,演示如何使用 gettimeofday 和 read 函数进行 IO 性能测试: ``` #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <fcntl.h> #include <unistd.h> #define BUF_SIZE 1024 int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "Usage: %s <file>\n", argv[0]); exit(EXIT_FAILURE); } int fd = open(argv[1], O_RDONLY); if (fd == -1) { perror("open"); exit(EXIT_FAILURE); } char buf[BUF_SIZE]; struct timeval start, end; gettimeofday(&start, NULL); while (read(fd, buf, BUF_SIZE) > 0) { // do nothing } gettimeofday(&end, NULL); double elapsed = (end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec) / 1000000.0; printf("Elapsed time: %.3f seconds\n", elapsed); close(fd); return 0; } ``` 这个程序用于读取一个文件,然后计算读取这个文件所花费的时间。可以在命令行运行,例如: ``` $ ./a.out test.txt Elapsed time: 0.003 seconds ``` 注意,这个示例程序没有进行任何的 IO 性能测试。如果您想进行更为详细和准确的测试,建议使用一些专业的工具。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值