Date: Wed, 8 Aug 2001 18:47:11 +0400 From: "Sergey A. Osokin" <osa@freebsd.org.ru> To: audit@FreeBSD.org Subject: [PATCH] libdevstat have two compute statistics functions Message-ID: <20010808184710.A87195@freebsd.org.ru>
next in thread | raw e-mail | index | archive | help
--envbJBWh7q8WU6mo Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello. After last commit into libdevstat, devstat.c containes 2 compute statistics functions: old compute_stats() and new devstat_compute_statistics(). I believe that compute_stats() is not necessary any more and we should remove it. devstat_compute_statistics() is a superset for compute_stats(). Thanks. -- Rgdz, /"\ Sergey Osokin aka oZZ, \ / ASCII RIBBON CAMPAIGN osa@freebsd.org.ru X AGAINST HTML MAIL http://freebsd.org.ru/~osa/ / \ --envbJBWh7q8WU6mo Content-Type: text/plain; charset=koi8-r Content-Disposition: attachment; filename="patch-devstat.c" Content-Transfer-Encoding: 8bit --- devstat.c.orig Wed Aug 8 14:44:11 2001 +++ devstat.c Wed Aug 8 14:55:21 2001 @@ -1129,89 +1129,16 @@ long double *mb_per_second, long double *blocks_per_second, long double *ms_per_transaction) { - u_int64_t totalbytes, totaltransfers, totalblocks; - char *func_name = "compute_stats"; - - /* - * current is the only mandatory field. - */ - if (current == NULL) { - snprintf(devstat_errbuf, sizeof(devstat_errbuf), - "%s: current stats structure was NULL", - func_name); - return(-1); - } - - totalbytes = (current->bytes_written + current->bytes_read) - - ((previous) ? (previous->bytes_written + - previous->bytes_read) : 0); - - if (total_bytes) - *total_bytes = totalbytes; - - totaltransfers = (current->num_reads + - current->num_writes + - current->num_other) - - ((previous) ? - (previous->num_reads + - previous->num_writes + - previous->num_other) : 0); - if (total_transfers) - *total_transfers = totaltransfers; - - if (transfers_per_second) { - if (etime > 0.0) { - *transfers_per_second = totaltransfers; - *transfers_per_second /= etime; - } else - *transfers_per_second = 0.0; - } - - if (kb_per_transfer) { - *kb_per_transfer = totalbytes; - *kb_per_transfer /= 1024; - if (totaltransfers > 0) - *kb_per_transfer /= totaltransfers; - else - *kb_per_transfer = 0.0; - } - - if (mb_per_second) { - *mb_per_second = totalbytes; - *mb_per_second /= 1024 * 1024; - if (etime > 0.0) - *mb_per_second /= etime; - else - *mb_per_second = 0.0; - } - - totalblocks = totalbytes; - if (current->block_size > 0) - totalblocks /= current->block_size; - else - totalblocks /= 512; - - if (total_blocks) - *total_blocks = totalblocks; - - if (blocks_per_second) { - *blocks_per_second = totalblocks; - if (etime > 0.0) - *blocks_per_second /= etime; - else - *blocks_per_second = 0.0; - } - - if (ms_per_transaction) { - if (totaltransfers > 0) { - *ms_per_transaction = etime; - *ms_per_transaction /= totaltransfers; - *ms_per_transaction *= 1000; - } else - *ms_per_transaction = 0.0; - } - - return(0); + return(devstat_compute_statistics(current, previous, etime, + DSM_TOTAL_BYTES, total_bytes, + DSM_TOTAL_TRANSFERS, total_transfers, + DSM_TOTAL_BLOCKS, total_blocks, + DSM_KB_PER_TRANSFER, kb_per_transfer, + DSM_TRANSFERS_PER_SECOND, transfers_per_second, + DSM_MB_PER_SECOND, mb_per_second, + DSM_BLOCKS_PER_SECOND, blocks_per_second, + DSM_MS_PER_TRANSACTION, ms_per_transaction, + DSM_NONE)); } long double --envbJBWh7q8WU6mo-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010808184710.A87195>