@@ -238,21 +238,35 @@ int main(int argc, char* argv[]) {
238
238
" mem" ,
239
239
" total" );
240
240
int n = limit;
241
+ const int delay_div = accumulated ? 1 : delay;
242
+ uint64_t total_read = 0 ;
243
+ uint64_t total_write = 0 ;
244
+ uint64_t total_read_write = 0 ;
241
245
for (const TaskStatistics& statistics : stats) {
242
- const int delay_div = accumulated ? 1 : delay;
243
- printf (" %6d %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " %5.2f%% %5.2f%% %5.2f%% %5.2f%% %5.2f%%\n " ,
244
- statistics.pid (),
245
- statistics.comm ().c_str (),
246
- BytesToKB (statistics.read ()) / delay_div,
247
- BytesToKB (statistics.write ()) / delay_div,
248
- BytesToKB (statistics.read_write ()) / delay_div,
249
- TimeToTgidPercent (statistics.delay_io (), delay, statistics),
250
- TimeToTgidPercent (statistics.delay_swap (), delay, statistics),
251
- TimeToTgidPercent (statistics.delay_sched (), delay, statistics),
252
- TimeToTgidPercent (statistics.delay_mem (), delay, statistics),
253
- TimeToTgidPercent (statistics.delay_total (), delay, statistics));
254
- if (n > 0 && --n == 0 ) break ;
246
+ total_read += statistics.read ();
247
+ total_write += statistics.write ();
248
+ total_read_write += statistics.read_write ();
249
+
250
+ if (n > 0 ) {
251
+ n--;
252
+ printf (" %6d %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " %5.2f%% %5.2f%% %5.2f%% %5.2f%% %5.2f%%\n " ,
253
+ statistics.pid (),
254
+ statistics.comm ().c_str (),
255
+ BytesToKB (statistics.read ()) / delay_div,
256
+ BytesToKB (statistics.write ()) / delay_div,
257
+ BytesToKB (statistics.read_write ()) / delay_div,
258
+ TimeToTgidPercent (statistics.delay_io (), delay, statistics),
259
+ TimeToTgidPercent (statistics.delay_swap (), delay, statistics),
260
+ TimeToTgidPercent (statistics.delay_sched (), delay, statistics),
261
+ TimeToTgidPercent (statistics.delay_mem (), delay, statistics),
262
+ TimeToTgidPercent (statistics.delay_total (), delay, statistics));
263
+ }
255
264
}
265
+ printf (" %6s %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " \n " , " " , " TOTAL" ,
266
+ BytesToKB (total_read) / delay_div,
267
+ BytesToKB (total_write) / delay_div,
268
+ BytesToKB (total_read_write) / delay_div);
269
+
256
270
second = false ;
257
271
258
272
if (cycles > 0 && --cycles == 0 ) break ;
0 commit comments