aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/time.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/miscutils/time.c b/miscutils/time.c
index 5a8fa4c0b..4b1b043c3 100644
--- a/miscutils/time.c
+++ b/miscutils/time.c
@@ -111,6 +111,7 @@ static void printargv(char *const *argv)
111 } while (*++argv); 111 } while (*++argv);
112} 112}
113 113
114#ifdef UNUSED
114/* Return the number of kilobytes corresponding to a number of pages PAGES. 115/* Return the number of kilobytes corresponding to a number of pages PAGES.
115 (Actually, we use it to convert pages*ticks into kilobytes*ticks.) 116 (Actually, we use it to convert pages*ticks into kilobytes*ticks.)
116 117
@@ -136,6 +137,7 @@ static unsigned long ptok(const unsigned pagesize, const unsigned long pages)
136 return tmp / 1024; /* then smaller. */ 137 return tmp / 1024; /* then smaller. */
137} 138}
138#undef pagesize 139#undef pagesize
140#endif /* UNUSED */
139 141
140/* summarize: Report on the system use of a command. 142/* summarize: Report on the system use of a command.
141 143
@@ -250,9 +252,13 @@ static void summarize(const char *fmt, char **command, resource_t *resp)
250 printargv(command); 252 printargv(command);
251 break; 253 break;
252 case 'D': /* Average unshared data size. */ 254 case 'D': /* Average unshared data size. */
255 /* (linux kernel sets ru_idrss/isrss/ixrss to 0,
256 * docs say the value is in kbytes, so ptok() is wrong) */
253 printf("%lu", 257 printf("%lu",
254 (ptok(pagesize, (UL) resp->ru.ru_idrss) + 258 (/*ptok(pagesize,*/ (UL) resp->ru.ru_idrss +
255 ptok(pagesize, (UL) resp->ru.ru_isrss)) / cpu_ticks); 259 (UL) resp->ru.ru_isrss
260 ) / cpu_ticks
261 );
256 break; 262 break;
257 case 'E': { /* Elapsed real (wall clock) time. */ 263 case 'E': { /* Elapsed real (wall clock) time. */
258 unsigned seconds = resp->elapsed_ms / 1000; 264 unsigned seconds = resp->elapsed_ms / 1000;
@@ -275,13 +281,17 @@ static void summarize(const char *fmt, char **command, resource_t *resp)
275 printf("%lu", resp->ru.ru_inblock); 281 printf("%lu", resp->ru.ru_inblock);
276 break; 282 break;
277 case 'K': /* Average mem usage == data+stack+text. */ 283 case 'K': /* Average mem usage == data+stack+text. */
284 /* (linux kernel sets ru_idrss/isrss/ixrss to 0,
285 * docs say the value is in kbytes, so ptok() is wrong) */
278 printf("%lu", 286 printf("%lu",
279 (ptok(pagesize, (UL) resp->ru.ru_idrss) + 287 (/*ptok(pagesize,*/ (UL) resp->ru.ru_idrss +
280 ptok(pagesize, (UL) resp->ru.ru_isrss) + 288 (UL) resp->ru.ru_isrss +
281 ptok(pagesize, (UL) resp->ru.ru_ixrss)) / cpu_ticks); 289 (UL) resp->ru.ru_ixrss
290 ) / cpu_ticks
291 );
282 break; 292 break;
283 case 'M': /* Maximum resident set size. */ 293 case 'M': /* Maximum resident set size. */
284 printf("%lu", ptok(pagesize, (UL) resp->ru.ru_maxrss)); 294 printf("%lu", (UL) resp->ru.ru_maxrss);
285 break; 295 break;
286 case 'O': /* Outputs. */ 296 case 'O': /* Outputs. */
287 printf("%lu", resp->ru.ru_oublock); 297 printf("%lu", resp->ru.ru_oublock);
@@ -334,7 +344,7 @@ static void summarize(const char *fmt, char **command, resource_t *resp)
334 printf("%lu", resp->ru.ru_nswap); 344 printf("%lu", resp->ru.ru_nswap);
335 break; 345 break;
336 case 'X': /* Average shared text size. */ 346 case 'X': /* Average shared text size. */
337 printf("%lu", ptok(pagesize, (UL) resp->ru.ru_ixrss) / cpu_ticks); 347 printf("%lu", /*ptok(pagesize,*/ (UL) resp->ru.ru_ixrss / cpu_ticks);
338 break; 348 break;
339 case 'Z': /* Page size. */ 349 case 'Z': /* Page size. */
340 printf("%u", pagesize); 350 printf("%u", pagesize);
@@ -351,7 +361,7 @@ static void summarize(const char *fmt, char **command, resource_t *resp)
351 printf("%lu", resp->ru.ru_nsignals); 361 printf("%lu", resp->ru.ru_nsignals);
352 break; 362 break;
353 case 'p': /* Average stack segment. */ 363 case 'p': /* Average stack segment. */
354 printf("%lu", ptok(pagesize, (UL) resp->ru.ru_isrss) / cpu_ticks); 364 printf("%lu", /*ptok(pagesize,*/ (UL) resp->ru.ru_isrss / cpu_ticks);
355 break; 365 break;
356 case 'r': /* Incoming socket messages received. */ 366 case 'r': /* Incoming socket messages received. */
357 printf("%lu", resp->ru.ru_msgrcv); 367 printf("%lu", resp->ru.ru_msgrcv);
@@ -360,7 +370,7 @@ static void summarize(const char *fmt, char **command, resource_t *resp)
360 printf("%lu", resp->ru.ru_msgsnd); 370 printf("%lu", resp->ru.ru_msgsnd);
361 break; 371 break;
362 case 't': /* Average resident set size. */ 372 case 't': /* Average resident set size. */
363 printf("%lu", ptok(pagesize, (UL) resp->ru.ru_idrss) / cpu_ticks); 373 printf("%lu", /*ptok(pagesize,*/ (UL) resp->ru.ru_idrss / cpu_ticks);
364 break; 374 break;
365 case 'w': /* Voluntary context switches. */ 375 case 'w': /* Voluntary context switches. */
366 printf("%lu", resp->ru.ru_nvcsw); 376 printf("%lu", resp->ru.ru_nvcsw);