Group **array;
signed path_columns;
unsigned rows, n = 0, j, maxtcpu = 0, maxtpath = 0;
Group **array;
signed path_columns;
unsigned rows, n = 0, j, maxtcpu = 0, maxtpath = 0;
/* Find the longest names in one run */
for (j = 0; j < n; j++) {
unsigned cputlen, pathtlen;
/* Find the longest names in one run */
for (j = 0; j < n; j++) {
unsigned cputlen, pathtlen;
- snprintf(cpu_title, sizeof(cpu_title), "%"PRIu64, array[j]->cpu_usage);
- cputlen = strlen(cpu_title);
+
+ format_timespan(buffer, sizeof(buffer), (nsec_t) (array[j]->cpu_usage / NSEC_PER_USEC), 0);
+ cputlen = strlen(buffer);
maxtcpu = MAX(maxtcpu, cputlen);
pathtlen = strlen(array[j]->path);
maxtpath = MAX(maxtpath, pathtlen);
}
if (arg_cpu_type == CPU_PERCENT)
maxtcpu = MAX(maxtcpu, cputlen);
pathtlen = strlen(array[j]->path);
maxtpath = MAX(maxtpath, pathtlen);
}
if (arg_cpu_type == CPU_PERCENT)
- snprintf(cpu_title, sizeof(cpu_title), "%6s", "%CPU");
+ snprintf(buffer, sizeof(buffer), "%6s", "%CPU");
- snprintf(cpu_title, sizeof(cpu_title), "%*s", maxtcpu, "CPU Time");
+ snprintf(buffer, sizeof(buffer), "%*s", maxtcpu, "CPU Time");
arg_order == ORDER_PATH ? OFF : "",
arg_order == ORDER_TASKS ? ON : "", "Tasks",
arg_order == ORDER_TASKS ? OFF : "",
arg_order == ORDER_PATH ? OFF : "",
arg_order == ORDER_TASKS ? ON : "", "Tasks",
arg_order == ORDER_TASKS ? OFF : "",
arg_order == ORDER_CPU ? OFF : "",
arg_order == ORDER_MEMORY ? ON : "", "Memory",
arg_order == ORDER_MEMORY ? OFF : "",
arg_order == ORDER_CPU ? OFF : "",
arg_order == ORDER_MEMORY ? ON : "", "Memory",
arg_order == ORDER_MEMORY ? OFF : "",
- else
- printf(" %*"PRIu64, maxtcpu, g->cpu_usage);
+ } else
+ printf(" %*s", maxtcpu, format_timespan(buffer, sizeof(buffer), (nsec_t) (g->cpu_usage / NSEC_PER_USEC), 0));
- printf(" %8s", format_bytes(m, sizeof(m), g->memory));
+ printf(" %8s", format_bytes(buffer, sizeof(buffer), g->memory));