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>
This commit is contained in:
Sébastien Bigaret 2017-03-11 07:40:19 +01:00 committed by Craig Small
parent cd289c88a0
commit 8a94ed6111
3 changed files with 30 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

@ -568,6 +568,12 @@ static int pr_time(char *restrict const outbuf, const proc_t *restrict const pp)
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 t = cook_time(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"
@ -1506,6 +1512,7 @@ static const format_struct format_array[] = {
{"cpu", "CPU", pr_nop, sr_nop, 3, 0, BSD, AN|RIGHT}, /* FIXME ... HP-UX wants this as the CPU number for SMP? */ {"cpu", "CPU", pr_nop, sr_nop, 3, 0, BSD, AN|RIGHT}, /* FIXME ... HP-UX wants this as the CPU number for SMP? */
{"cpuid", "CPUID", pr_psr, sr_nop, 5, 0, BSD, TO|RIGHT}, // OpenBSD: 8 wide! {"cpuid", "CPUID", pr_psr, sr_nop, 5, 0, BSD, TO|RIGHT}, // OpenBSD: 8 wide!
{"cputime", "TIME", pr_time, sr_time, 8, 0, DEC, ET|RIGHT}, /*time*/ {"cputime", "TIME", pr_time, sr_time, 8, 0, DEC, ET|RIGHT}, /*time*/
{"cputimes", "TIME", pr_times, sr_time, 8, 0, LNX, ET|RIGHT}, /*time*/
{"ctid", "CTID", pr_nop, sr_nop, 5, 0, SUN, ET|RIGHT}, // resource contracts? {"ctid", "CTID", pr_nop, sr_nop, 5, 0, SUN, ET|RIGHT}, // resource contracts?
{"cursig", "CURSIG", pr_nop, sr_nop, 6, 0, DEC, AN|RIGHT}, {"cursig", "CURSIG", pr_nop, sr_nop, 6, 0, DEC, AN|RIGHT},
{"cutime", "-", pr_nop, sr_cutime, 1, 0, LNX, AN|RIGHT}, {"cutime", "-", pr_nop, sr_cutime, 1, 0, LNX, AN|RIGHT},
@ -1678,6 +1685,7 @@ static const format_struct format_array[] = {
{"thcount", "THCNT", pr_nlwp, sr_nlwp, 5, 0, AIX, PO|RIGHT}, {"thcount", "THCNT", pr_nlwp, sr_nlwp, 5, 0, AIX, PO|RIGHT},
{"tid", "TID", pr_tasks, sr_tasks, 5, 0, AIX, TO|PIDMAX|RIGHT}, {"tid", "TID", pr_tasks, sr_tasks, 5, 0, AIX, TO|PIDMAX|RIGHT},
{"time", "TIME", pr_time, sr_time, 8, 0, U98, ET|RIGHT}, /*cputime*/ /* was 6 wide */ {"time", "TIME", pr_time, sr_time, 8, 0, U98, ET|RIGHT}, /*cputime*/ /* was 6 wide */
{"times", "TIME", pr_times, sr_time, 8, 0, LNX, ET|RIGHT},
{"timeout", "TMOUT", pr_nop, sr_nop, 5, 0, LNX, AN|RIGHT}, // 2.0.xx era {"timeout", "TMOUT", pr_nop, sr_nop, 5, 0, LNX, AN|RIGHT}, // 2.0.xx era
{"tmout", "TMOUT", pr_nop, sr_nop, 5, 0, LNX, AN|RIGHT}, // 2.0.xx era {"tmout", "TMOUT", pr_nop, sr_nop, 5, 0, LNX, AN|RIGHT}, // 2.0.xx era
{"tname", "TTY", pr_tty8, sr_tty, 8, 0, DEC, PO|LEFT}, {"tname", "TTY", pr_tty8, sr_tty, 8, 0, DEC, PO|LEFT},

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.
@ -1727,6 +1732,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 ).