From ab25fa1db20b5c1b6784e1cb0e5f7e027804fde6 Mon Sep 17 00:00:00 2001 From: sos Date: Tue, 9 Nov 2004 12:28:41 +0000 Subject: Add -c option that calculates the overhead of read I/O ops. --- usr.sbin/diskinfo/diskinfo.8 | 4 ++++ usr.sbin/diskinfo/diskinfo.c | 46 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) (limited to 'usr.sbin/diskinfo') diff --git a/usr.sbin/diskinfo/diskinfo.8 b/usr.sbin/diskinfo/diskinfo.8 index a89c25d..9c7c131 100644 --- a/usr.sbin/diskinfo/diskinfo.8 +++ b/usr.sbin/diskinfo/diskinfo.8 @@ -54,6 +54,10 @@ If given the option, the fields will be printed one per line with a descriptive comment. .Pp The +.Fl c +option triggers a simple measurement of the I/O read command overhead. +.Pp +The .Fl t option triggers a simple and rather naive benchmark of the disks seek and transfer performance. diff --git a/usr.sbin/diskinfo/diskinfo.c b/usr.sbin/diskinfo/diskinfo.c index 5203a7b..3ad2a55 100644 --- a/usr.sbin/diskinfo/diskinfo.c +++ b/usr.sbin/diskinfo/diskinfo.c @@ -48,9 +48,10 @@ usage(void) exit (1); } -static int opt_t, opt_v; +static int opt_c, opt_t, opt_v; static void speeddisk(int fd, off_t mediasize, u_int sectorsize); +static void commandtime(int fd, off_t mediasize, u_int sectorsize); int main(int argc, char **argv) @@ -60,8 +61,12 @@ main(int argc, char **argv) off_t mediasize; u_int sectorsize, fwsectors, fwheads; - while ((ch = getopt(argc, argv, "tv")) != -1) { + while ((ch = getopt(argc, argv, "ctv")) != -1) { switch (ch) { + case 'c': + opt_c = 1; + opt_v = 1; + break; case 't': opt_t = 1; opt_v = 1; @@ -127,6 +132,8 @@ main(int argc, char **argv) } } printf("\n"); + if (opt_c) + commandtime(fd, mediasize, sectorsize); if (opt_t) speeddisk(fd, mediasize, sectorsize); close(fd); @@ -305,6 +312,41 @@ speeddisk(int fd, off_t mediasize, u_int sectorsize) TR(100 * 1024); printf("\n"); + return; +} + +static void +commandtime(int fd, off_t mediasize, u_int sectorsize) +{ + double dtmega, dtsector; + int i; + printf("I/O command overhead:\n"); + i = mediasize; + rdsect(fd, 0, sectorsize); + T0(); + for (i = 0; i < 10; i++) + rdmega(fd); + gettimeofday(&tv2, NULL); + dtmega = (tv2.tv_usec - tv1.tv_usec) / 1e6; + dtmega += (tv2.tv_sec - tv1.tv_sec); + + printf("\ttime to read 10MB block %10.6f sec\t= %8.3f msec/sector\n", + dtmega, dtmega*100/2048); + + rdsect(fd, 0, sectorsize); + T0(); + for (i = 0; i < 20480; i++) + rdsect(fd, 0, sectorsize); + gettimeofday(&tv2, NULL); + dtsector = (tv2.tv_usec - tv1.tv_usec) / 1e6; + dtsector += (tv2.tv_sec - tv1.tv_sec); + + printf("\ttime to read 20480 sectors %10.6f sec\t= %8.3f msec/sector\n", + dtsector, dtsector*100/2048); + printf("\tcalculated command overhead\t\t\t= %8.3f msec/sector\n", + (dtsector - dtmega)*100/2048); + + printf("\n"); return; } -- cgit v1.1