diff options
author | Colin Cross <ccross@android.com> | 2015-09-08 17:09:22 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2015-09-08 17:09:22 -0700 |
commit | c5cacc116757d1d38b158368f5d414b007dd6462 (patch) | |
tree | f4df052728a540c2596fc9d797dbafb1ddc5620c /iotop | |
parent | a1bc8d7d45519b47fbc2dd13c47f4c4478b3285c (diff) | |
download | extras-c5cacc116757d1d38b158368f5d414b007dd6462.tar.gz |
iotop: add total read/write stats
Provide total read, write, and read/write stats across all threads
or processes.
Change-Id: I7dc2edd45681b6a54f67347337c76deb1342dc95
Diffstat (limited to 'iotop')
-rw-r--r-- | iotop/iotop.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/iotop/iotop.cpp b/iotop/iotop.cpp index 1b8628eb..645490df 100644 --- a/iotop/iotop.cpp +++ b/iotop/iotop.cpp @@ -238,21 +238,35 @@ int main(int argc, char* argv[]) { "mem", "total"); int n = limit; + const int delay_div = accumulated ? 1 : delay; + uint64_t total_read = 0; + uint64_t total_write = 0; + uint64_t total_read_write = 0; for (const TaskStatistics& statistics : stats) { - const int delay_div = accumulated ? 1 : delay; - printf("%6d %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " %5.2f%% %5.2f%% %5.2f%% %5.2f%% %5.2f%%\n", - statistics.pid(), - statistics.comm().c_str(), - BytesToKB(statistics.read()) / delay_div, - BytesToKB(statistics.write()) / delay_div, - BytesToKB(statistics.read_write()) / delay_div, - TimeToTgidPercent(statistics.delay_io(), delay, statistics), - TimeToTgidPercent(statistics.delay_swap(), delay, statistics), - TimeToTgidPercent(statistics.delay_sched(), delay, statistics), - TimeToTgidPercent(statistics.delay_mem(), delay, statistics), - TimeToTgidPercent(statistics.delay_total(), delay, statistics)); - if (n > 0 && --n == 0) break; + total_read += statistics.read(); + total_write += statistics.write(); + total_read_write += statistics.read_write(); + + if (n > 0) { + n--; + printf("%6d %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " %5.2f%% %5.2f%% %5.2f%% %5.2f%% %5.2f%%\n", + statistics.pid(), + statistics.comm().c_str(), + BytesToKB(statistics.read()) / delay_div, + BytesToKB(statistics.write()) / delay_div, + BytesToKB(statistics.read_write()) / delay_div, + TimeToTgidPercent(statistics.delay_io(), delay, statistics), + TimeToTgidPercent(statistics.delay_swap(), delay, statistics), + TimeToTgidPercent(statistics.delay_sched(), delay, statistics), + TimeToTgidPercent(statistics.delay_mem(), delay, statistics), + TimeToTgidPercent(statistics.delay_total(), delay, statistics)); + } } + printf("%6s %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 "\n", "", "TOTAL", + BytesToKB(total_read) / delay_div, + BytesToKB(total_write) / delay_div, + BytesToKB(total_read_write) / delay_div); + second = false; if (cycles > 0 && --cycles == 0) break; |