Skip to content

Commit

Permalink
Remove spaces from field labels.
Browse files Browse the repository at this point in the history
The %Z specifier is also removed.
  • Loading branch information
ayosec committed Aug 26, 2021
1 parent d21ac05 commit 8da2bda
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
1 change: 0 additions & 1 deletion FORMAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ The following resource specifiers are accepted in the format string:
|`%U`<br>`%(user_time)` | User time (seconds). |
|`%w`<br>`%(nvcsw)` | Voluntary context switches. |
|`%x`<br>`%(status)` | Exit status of command. |
|`%Z`<br>`%(page_size)` | Page size. |

## Options

Expand Down
27 changes: 11 additions & 16 deletions src/format/format.spec
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@
}

: %F %(majflt)
//! [label] MAJOR FLT.
//! [label] MAJFL
//! Major page faults (required physical I/O).
rusage_field!(ru_majflt);

: %I %(inblock)
//! [label] INPUT OPS.
//! [label] FSIN
//! File system inputs.
rusage_field!(ru_inblock);

: %M %(maxrss)
//! [label] MAX. RSS
//! [label] MAXRSS
//! Maximum resident set size in Kib.
rusage_field!(ru_maxrss);

: %O %(oublock)
//! [label] OUTPUT OPS.
//! [label] FSOUT
//! File system outputs.
rusage_field!(ru_oublock);

Expand All @@ -125,28 +125,28 @@
}

: %R %(minflt)
//! [label] MINOR FLT.
//! [label] MINFL
//! Minor page faults (reclaims; no physical I/O involved).
rusage_field!(ru_minflt);

: %S %(sys_time)
//! [label] SYS. TIME
//! [label] SYSTIME
//! System (kernel) time (seconds).
if let State::Finished { rusage, .. } = &entry.state {
let time = &rusage.ru_stime;
w!("{}.{:03}", time.tv_sec, time.tv_usec / 1000);
}

: %(sys_time_us)
//! [label] SYS. TIME
//! [label] SYSTIME
//! System (kernel) time (microseconds).
if let State::Finished { rusage, .. } = &entry.state {
let time = &rusage.ru_stime;
w!("{}", time.tv_sec * 1_000_000 + time.tv_usec);
}

: %Tt
//! [label] TERMINATION
//! [label] EXTYPE
//! Termination type: normal, signalled, stopped.
if let State::Finished { status, .. } = &entry.state {
w!(
Expand Down Expand Up @@ -175,26 +175,21 @@
}

: %U %(user_time)
//! [label] USER TIME
//! [label] USERTIME
//! User time (seconds).
if let State::Finished { rusage, .. } = &entry.state {
let time = &rusage.ru_utime;
w!("{}.{:03}", time.tv_sec, time.tv_usec / 1000);
}

: %(user_time_us)
//! [label] USER TIME
//! [label] USERTIME
//! User time (microseconds).
if let State::Finished { rusage, .. } = &entry.state {
let time = &rusage.ru_utime;
w!("{}", time.tv_sec * 1_000_000 + time.tv_usec);
}

: %Z %(page_size)
//! [label] PAGE SIZE
//! Page size.
w!(unsafe { libc::sysconf(libc::_SC_PAGESIZE) });

: %c %(nivcsw)
//! [label] IVCSW
//! Involuntary context switches.
Expand Down Expand Up @@ -237,7 +232,7 @@
w!(entry.pid);

: %(time:
//! [label] TIME
//! [label] STARTED
//! [label-until] )
//! [alias] %(time:FORMAT)
//! Start time with a custom format.
Expand Down
2 changes: 1 addition & 1 deletion src/format/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ fn render_labels() {
.unwrap();
assert_eq!(
std::str::from_utf8(&output),
Ok("PID - %(piMAX. RSS - TIME - \u{221e}")
Ok("PID - %(piMAXRSS - STARTED - \u{221e}")
);
}
1 change: 0 additions & 1 deletion src/format/verbose.fmt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ Voluntary context switches: %w
Involuntary context switches: %c
File system inputs: %I
File system outputs: %O
Page size (bytes): %Z
Exit status: %x

0 comments on commit 8da2bda

Please sign in to comment.