#[non_exhaustive]pub struct RunProfile {
pub outcome: Outcome,
pub duration: Duration,
pub cpu_time: Option<Duration>,
pub peak_memory_bytes: Option<u64>,
pub samples: usize,
}stats only.Expand description
Resource summary of one finished run — produced by
RunningProcess::profile.
CPU and memory are sampled from the started child process (the same
source as RunningProcess::cpu_time /
peak_memory_bytes), so they
are None where per-process metrics are unavailable (macOS/BSD) or when
the run exited before the first sample landed.
§Scope: the run’s own process, not its tree
Everything here describes the process this run started. A child that process
forks is contained by the group the run belongs to, but its CPU and memory
are not in these numbers, and the whole-tree counters a containment mechanism
keeps — ProcessGroupStats::io_read_bytes, io_write_bytes and
peak_process_count — are deliberately not mirrored onto this summary.
They are group-level facts, and a run does not have a whole-tree scope of its
own to report them under. A run started through
Command::start gets a fresh private group, whose
tree is exactly this run’s; a run started into a
ProcessGroup shares it with every other run in that group, and a
container’s counters cannot be split back into per-run shares. Copying them
here would put a number that means “this run’s tree” for one call and
“somebody else’s processes too” for the next under a single per-run name.
When the whole-tree question is the one you have, start the run into a
ProcessGroup you created for it alone and read
ProcessGroup::stats — which is the same group, named as what it is.
Non-exhaustive: a read-only summary the crate produces — new metrics can be added without a breaking change.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.outcome: OutcomeHow the run ended — the full Outcome, so a profile can
distinguish a clean exit from a signal kill from a timeout (all three of
which leave code None). Read it directly, or
via the code / signal /
timed_out convenience accessors. The profile is
therefore a superset of
RunningProcess::wait: one call yields both
the resource telemetry and the run’s actual outcome.
duration: DurationWall-clock time from process start until the run finished (exit reaped and output drained).
cpu_time: Option<Duration>Cumulative CPU time (user + kernel) at the last successful sample.
peak_memory_bytes: Option<u64>Peak resident memory observed across the samples, in bytes.
samples: usizeHow many sampling ticks ran (including ones that found no data).
Implementations§
Source§impl RunProfile
impl RunProfile
Sourcepub fn avg_cpu_cores(&self) -> Option<f64>
pub fn avg_cpu_cores(&self) -> Option<f64>
Average CPU utilisation over the run, in cores (0.5 = half a core
busy on average; can exceed 1.0 for multi-threaded children).
None when CPU time was never observed or the run had no duration.
Sourcepub fn code(&self) -> Option<i32>
pub fn code(&self) -> Option<i32>
The exit code if the run exited, else None
(a signal kill or a timeout). Equals
outcome.code(); the method form completes the
code() / signal() / timed_out()
accessor trio that mirrors ProcessResult and
Outcome.
Sourcepub fn signal(&self) -> Option<i32>
pub fn signal(&self) -> Option<i32>
The signal that killed the run, if it was
signalled with a known number (None on a
clean exit, a timeout, or a signal kill the platform didn’t number).
Shorthand for outcome.signal().
Sourcepub fn timed_out(&self) -> bool
pub fn timed_out(&self) -> bool
Whether the run was killed by its
timeout. Shorthand for
outcome.timed_out() — distinguishes a
deadline kill from a signal kill, which code alone
(both None) cannot.
Sourcepub fn inactivity_timed_out(&self) -> bool
pub fn inactivity_timed_out(&self) -> bool
Whether the run was killed specifically by its output-inactivity
watchdog. Shorthand for
outcome.inactivity_timed_out().
Trait Implementations§
Source§impl Clone for RunProfile
impl Clone for RunProfile
Source§fn clone(&self) -> RunProfile
fn clone(&self) -> RunProfile
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RunProfile
Source§impl Debug for RunProfile
impl Debug for RunProfile
impl Eq for RunProfile
Source§impl PartialEq for RunProfile
impl PartialEq for RunProfile
Source§impl Serialize for RunProfile
Available on crate feature report-serde only.(feature report-serde) The run summary, field for field:
impl Serialize for RunProfile
report-serde only.(feature report-serde) The run summary, field for field:
{
"outcome": {"kind": "exited", "code": 0, "signal_number": null},
"duration_secs": 2.0,
"cpu_time_secs": 1.0,
"peak_memory_bytes": 4096,
"samples": 8
}cpu_time_secs / peak_memory_bytes are null wherever the platform could
not measure them or the run ended before the first sample landed — the same
honest gap the Option fields carry. avg_cpu_cores
is deliberately not a key: it is arithmetic over two fields already
here, and this schema reports facts rather than restating derivations (the
one exception, ProcessResult’s success, exists because accepted-exit
policy is the crate’s, not the consumer’s).