ps: add times & cputimes format specifiers: cumulative CPU time in seconds

These format specifiers are to time & cputime what etimes is to etime.

Signed-off-by: Sébastien Bigaret <sebastien.bigaret@telecom-bretagne.eu>

References:
 procps-ng/procps!43
This commit is contained in:
Sébastien Bigaret 2017-03-11 07:40:19 +01:00 committed by Craig Small
parent 39cd65c798
commit 5329984b2e
3 changed files with 32 additions and 0 deletions

View File

@ -4662,6 +4662,12 @@ msgstr "Le programme B<watch> a été écrit par Tony Rems E<lt>I<rembo@unisoft.
#~ msgid "cumulative CPU time, \"[DD-]hh:mm:ss\" format. (alias\n" #~ msgid "cumulative CPU time, \"[DD-]hh:mm:ss\" format. (alias\n"
#~ msgstr "Temps CPU cumulé, au format « [JJ-]HH:MM:SS » (alias\n" #~ msgstr "Temps CPU cumulé, au format « [JJ-]HH:MM:SS » (alias\n"
#~ msgid "cputimes\tTIME\tT{\n"
#~ msgstr "cputimes\tTIME\tT{\n"
#~ msgid "cumulative CPU time in seconds (alias\n"
#~ msgstr "Temps CPU cumulé en secondes (alias\n"
#~ msgid "B<time>).\n" #~ msgid "B<time>).\n"
#~ msgstr "B<time>).\n" #~ msgstr "B<time>).\n"
@ -5537,6 +5543,12 @@ msgstr "Le programme B<watch> a été écrit par Tony Rems E<lt>I<rembo@unisoft.
#~ msgid "cumulative CPU\\ time, \"[DD-]HH:MM:SS\" format. (alias\n" #~ msgid "cumulative CPU\\ time, \"[DD-]HH:MM:SS\" format. (alias\n"
#~ msgstr "Temps CPU cumulé, au format « [JJ-]HH:MM:SS » (alias\n" #~ msgstr "Temps CPU cumulé, au format « [JJ-]HH:MM:SS » (alias\n"
#~ msgid "times\tTIME\tT{\n"
#~ msgstr "times\tTIME\tT{\n"
#~ msgid "cumulative CPU\\ time in seconds (alias\n"
#~ msgstr "Temps CPU cumulé en secondes (alias\n"
#~ msgid "B<cputime>).\n" #~ msgid "B<cputime>).\n"
#~ msgstr "B<cputime>).\n" #~ msgstr "B<cputime>).\n"

View File

@ -444,6 +444,14 @@ setREL1(TIME_ALL)
return c; return c;
} }
/* cumulative CPU time in seconds (not same as "etimes") */
static int pr_times(char *restrict const outbuf, const proc_t *restrict const pp){
unsigned long t;
setREL1(TIME_ALL)
t = rSv(TIME_ALL, ull_int, pp);
return snprintf(outbuf, COLWID, "%u", t);
}
/* HP-UX puts this (I forget, vsz or vsize?) in kB and uses "sz" for pages. /* HP-UX puts this (I forget, vsz or vsize?) in kB and uses "sz" for pages.
* Unix98 requires "vsz" to be kB. * Unix98 requires "vsz" to be kB.
* Tru64 does both vsize and vsz like "1.23M" * Tru64 does both vsize and vsz like "1.23M"
@ -1385,6 +1393,7 @@ static const format_struct format_array[] = { /*
{"cpu", "CPU", pr_nop, PIDS_noop, 3, BSD, AN|RIGHT}, /* FIXME ... HP-UX wants this as the CPU number for SMP? */ {"cpu", "CPU", pr_nop, PIDS_noop, 3, BSD, AN|RIGHT}, /* FIXME ... HP-UX wants this as the CPU number for SMP? */
{"cpuid", "CPUID", pr_psr, PIDS_PROCESSOR, 5, BSD, TO|RIGHT}, // OpenBSD: 8 wide! {"cpuid", "CPUID", pr_psr, PIDS_PROCESSOR, 5, BSD, TO|RIGHT}, // OpenBSD: 8 wide!
{"cputime", "TIME", pr_time, PIDS_TIME_ALL, 8, DEC, ET|RIGHT}, /*time*/ {"cputime", "TIME", pr_time, PIDS_TIME_ALL, 8, DEC, ET|RIGHT}, /*time*/
{"cputimes", "TIME", pr_times, PIDS_TIME_ALL, 8, LNX, ET|RIGHT}, /*time*/
{"ctid", "CTID", pr_nop, PIDS_noop, 5, SUN, ET|RIGHT}, // resource contracts? {"ctid", "CTID", pr_nop, PIDS_noop, 5, SUN, ET|RIGHT}, // resource contracts?
{"cursig", "CURSIG", pr_nop, PIDS_noop, 6, DEC, AN|RIGHT}, {"cursig", "CURSIG", pr_nop, PIDS_noop, 6, DEC, AN|RIGHT},
{"cutime", "-", pr_nop, PIDS_TICS_USER_C, 1, LNX, AN|RIGHT}, {"cutime", "-", pr_nop, PIDS_TICS_USER_C, 1, LNX, AN|RIGHT},
@ -1558,6 +1567,7 @@ static const format_struct format_array[] = { /*
{"tid", "TID", pr_tasks, PIDS_ID_PID, 5, AIX, TO|PIDMAX|RIGHT}, {"tid", "TID", pr_tasks, PIDS_ID_PID, 5, AIX, TO|PIDMAX|RIGHT},
{"time", "TIME", pr_time, PIDS_TIME_ALL, 8, U98, ET|RIGHT}, /*cputime*/ /* was 6 wide */ {"time", "TIME", pr_time, PIDS_TIME_ALL, 8, U98, ET|RIGHT}, /*cputime*/ /* was 6 wide */
{"timeout", "TMOUT", pr_nop, PIDS_noop, 5, LNX, AN|RIGHT}, // 2.0.xx era {"timeout", "TMOUT", pr_nop, PIDS_noop, 5, LNX, AN|RIGHT}, // 2.0.xx era
{"times", "TIME", pr_times, PIDS_TIME_ALL, 8, LNX, ET|RIGHT},
{"tmout", "TMOUT", pr_nop, PIDS_noop, 5, LNX, AN|RIGHT}, // 2.0.xx era {"tmout", "TMOUT", pr_nop, PIDS_noop, 5, LNX, AN|RIGHT}, // 2.0.xx era
{"tname", "TTY", pr_tty8, PIDS_TTY_NAME, 8, DEC, PO|LEFT}, {"tname", "TTY", pr_tty8, PIDS_TTY_NAME, 8, DEC, PO|LEFT},
{"tpgid", "TPGID", pr_tpgid, PIDS_ID_TPGID, 5, XXX, PO|PIDMAX|RIGHT}, {"tpgid", "TPGID", pr_tpgid, PIDS_ID_TPGID, 5, XXX, PO|PIDMAX|RIGHT},

10
ps/ps.1
View File

@ -1192,6 +1192,11 @@ cumulative CPU time, "[DD\-]hh:mm:ss" format. (alias
.BR time ). .BR time ).
T} T}
cputimes TIME T{
cumulative CPU time in seconds (alias
.BR times ).
T}
drs DRS T{ drs DRS T{
data resident set size, the amount of physical memory devoted to other than data resident set size, the amount of physical memory devoted to other than
executable code. executable code.
@ -1726,6 +1731,11 @@ cumulative CPU\ time, "[DD\-]HH:MM:SS" format. (alias
.BR cputime ). .BR cputime ).
T} T}
times TIME T{
cumulative CPU\ time in seconds (alias
.BR cputimes ).
T}
tname TTY T{ tname TTY T{
controlling tty (terminal). (alias controlling tty (terminal). (alias
.BR tt , \ tty ). .BR tt , \ tty ).