Skip to main content

wowlab_engine_ports/
progress.rs

1/// Called at sim start with job metadata.
2#[derive(Debug)]
3pub struct ProgressStart {
4    pub job_id: String,
5    pub chunk_id: String,
6    pub iterations: u32,
7}
8
9/// Called periodically from the sim loop.
10#[derive(Debug, Default)]
11#[non_exhaustive]
12pub struct ProgressTick {
13    pub chunk_id: String,
14    pub iterations_completed: u32,
15    pub iterations_total: u32,
16
17    pub throughput_sps: Option<f64>,
18    pub running_mean_dps: Option<f64>,
19    pub running_std_dps: Option<f64>,
20    pub running_min_dps: Option<f64>,
21    pub running_max_dps: Option<f64>,
22    /// `std / sqrt(n) / mean` as a fraction; `None` while `n < 2` or mean <= 0.
23    pub relative_stderr: Option<f64>,
24    pub elapsed_ms: Option<u64>,
25}
26
27impl ProgressTick {
28    #[must_use]
29    pub fn new(chunk_id: String, iterations_completed: u32, iterations_total: u32) -> Self {
30        Self {
31            chunk_id,
32            iterations_completed,
33            iterations_total,
34            ..Default::default()
35        }
36    }
37}
38
39/// Called when the chunk finishes.
40#[derive(Debug)]
41pub struct ProgressDone {
42    pub chunk_id: String,
43    pub iterations_completed: u32,
44}
45
46/// Progress reporting contract. Hosts implement throttling in their sink.
47pub trait ProgressSink: Send + Sync {
48    fn on_start(&self, meta: ProgressStart);
49    fn on_tick(&self, tick: ProgressTick);
50    fn on_complete(&self, done: ProgressDone);
51}
52
53/// No-op progress sink.
54#[derive(Debug)]
55pub struct NoopProgress;
56
57impl ProgressSink for NoopProgress {
58    fn on_start(&self, _meta: ProgressStart) {}
59    fn on_tick(&self, _tick: ProgressTick) {}
60    fn on_complete(&self, _done: ProgressDone) {}
61}