@@ -41,6 +41,7 @@ static float TimeToTgidPercent(uint64_t ns, int time, const TaskStatistics& stat
41
41
static void usage (char * myname) {
42
42
printf (
43
43
" Usage: %s [-h] [-P] [-d <delay>] [-n <cycles>] [-s <column>]\n "
44
+ " -a Show byte count instead of rate\n "
44
45
" -d Set the delay between refreshes in seconds.\n "
45
46
" -h Display this help screen.\n "
46
47
" -m Set the number of processes or threads to show\n "
@@ -97,6 +98,7 @@ static Sorter GetSorter(const std::string field) {
97
98
}
98
99
99
100
int main (int argc, char * argv[]) {
101
+ bool accumulated = false ;
100
102
bool processes = false ;
101
103
int delay = 1 ;
102
104
int cycles = -1 ;
@@ -108,6 +110,7 @@ int main(int argc, char* argv[]) {
108
110
while (1 ) {
109
111
int c;
110
112
static const option longopts[] = {
113
+ {" accumulated" , 0 , 0 , ' a' },
111
114
{" delay" , required_argument, 0 , ' d' },
112
115
{" help" , 0 , 0 , ' h' },
113
116
{" limit" , required_argument, 0 , ' m' },
@@ -116,11 +119,14 @@ int main(int argc, char* argv[]) {
116
119
{" processes" , 0 , 0 , ' P' },
117
120
{0 , 0 , 0 , 0 },
118
121
};
119
- c = getopt_long (argc, argv, " d :hm:n:Ps:" , longopts, NULL );
122
+ c = getopt_long (argc, argv, " ad :hm:n:Ps:" , longopts, NULL );
120
123
if (c < 0 ) {
121
124
break ;
122
125
}
123
126
switch (c) {
127
+ case ' a' :
128
+ accumulated = true ;
129
+ break ;
124
130
case ' d' :
125
131
delay = atoi (optarg);
126
132
break ;
@@ -213,8 +219,13 @@ int main(int argc, char* argv[]) {
213
219
if (!second) {
214
220
printf (" \n " );
215
221
}
216
- printf (" %6s %-16s %20s %34s\n " , " " , " " ,
217
- " --- IO (KiB/s) ---" , " ----------- delayed on ----------" );
222
+ if (accumulated) {
223
+ printf (" %6s %-16s %20s %34s\n " , " " , " " ,
224
+ " ---- IO (KiB) ----" , " ----------- delayed on ----------" );
225
+ } else {
226
+ printf (" %6s %-16s %20s %34s\n " , " " , " " ,
227
+ " --- IO (KiB/s) ---" , " ----------- delayed on ----------" );
228
+ }
218
229
printf (" %6s %-16s %6s %6s %6s %-5s %-5s %-5s %-5s %-5s\n " ,
219
230
" PID" ,
220
231
" Command" ,
@@ -228,12 +239,13 @@ int main(int argc, char* argv[]) {
228
239
" total" );
229
240
int n = limit;
230
241
for (const TaskStatistics& statistics : stats) {
242
+ const int delay_div = accumulated ? 1 : delay;
231
243
printf (" %6d %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " %5.2f%% %5.2f%% %5.2f%% %5.2f%% %5.2f%%\n " ,
232
244
statistics.pid (),
233
245
statistics.comm ().c_str (),
234
- BytesToKB (statistics.read ()),
235
- BytesToKB (statistics.write ()),
236
- BytesToKB (statistics.read_write ()),
246
+ BytesToKB (statistics.read ()) / delay_div ,
247
+ BytesToKB (statistics.write ()) / delay_div ,
248
+ BytesToKB (statistics.read_write ()) / delay_div ,
237
249
TimeToTgidPercent (statistics.delay_io (), delay, statistics),
238
250
TimeToTgidPercent (statistics.delay_swap (), delay, statistics),
239
251
TimeToTgidPercent (statistics.delay_sched (), delay, statistics),
0 commit comments