pub struct SolveStats {
pub iterations: u32,
pub duration_us: u64,
pub peak_memory: u64,
}Expand description
Statistics from a solve operation.
Tracks performance metrics from solver execution including iteration count, timing, and memory usage.
§Builder Pattern
SolveStats supports a builder pattern for convenient construction:
use xlog_solve::SolveStats;
let stats = SolveStats::default()
.with_iterations(100)
.with_duration_us(5000)
.with_peak_memory(1024);
assert_eq!(stats.iterations, 100);
assert_eq!(stats.duration_us, 5000);
assert_eq!(stats.peak_memory, 1024);Fields§
§iterations: u32Number of iterations performed by the solver.
For iterative solvers (like CLS), this is the number of gradient descent steps. For CDCL solvers, this might be the number of decisions or conflicts.
duration_us: u64Wall-clock time spent solving, in microseconds.
This includes all solver operations but typically excludes instance setup and result extraction.
peak_memory: u64Peak memory usage during solving, in bytes.
This tracks the maximum memory allocated by the solver, useful for profiling and resource management.
Implementations§
Source§impl SolveStats
impl SolveStats
Sourcepub const fn new(iterations: u32, duration_us: u64, peak_memory: u64) -> Self
pub const fn new(iterations: u32, duration_us: u64, peak_memory: u64) -> Self
Creates new statistics with all fields specified.
§Arguments
iterations- Number of solver iterationsduration_us- Solve time in microsecondspeak_memory- Peak memory usage in bytes
§Example
use xlog_solve::SolveStats;
let stats = SolveStats::new(100, 5000, 1024);
assert_eq!(stats.iterations, 100);Sourcepub const fn with_iterations(self, iterations: u32) -> Self
pub const fn with_iterations(self, iterations: u32) -> Self
Sets the iteration count, consuming and returning self.
§Example
use xlog_solve::SolveStats;
let stats = SolveStats::default().with_iterations(100);
assert_eq!(stats.iterations, 100);Sourcepub const fn with_duration_us(self, duration_us: u64) -> Self
pub const fn with_duration_us(self, duration_us: u64) -> Self
Sets the duration in microseconds, consuming and returning self.
§Example
use xlog_solve::SolveStats;
let stats = SolveStats::default().with_duration_us(5000);
assert_eq!(stats.duration_us, 5000);Sourcepub const fn with_peak_memory(self, peak_memory: u64) -> Self
pub const fn with_peak_memory(self, peak_memory: u64) -> Self
Sets the peak memory usage in bytes, consuming and returning self.
§Example
use xlog_solve::SolveStats;
let stats = SolveStats::default().with_peak_memory(1024);
assert_eq!(stats.peak_memory, 1024);Sourcepub const fn duration_ms(&self) -> u64
pub const fn duration_ms(&self) -> u64
Returns the duration in milliseconds (rounded down).
§Example
use xlog_solve::SolveStats;
let stats = SolveStats::new(0, 5500, 0);
assert_eq!(stats.duration_ms(), 5);Sourcepub fn duration_secs(&self) -> f64
pub fn duration_secs(&self) -> f64
Returns the duration in seconds as a floating-point value.
§Example
use xlog_solve::SolveStats;
let stats = SolveStats::new(0, 1_500_000, 0);
assert_eq!(stats.duration_secs(), 1.5);Sourcepub fn iterations_per_sec(&self) -> f64
pub fn iterations_per_sec(&self) -> f64
Returns iterations per second (throughput).
Returns 0.0 if duration is zero.
§Example
use xlog_solve::SolveStats;
let stats = SolveStats::new(1000, 1_000_000, 0);
assert_eq!(stats.iterations_per_sec(), 1000.0);Trait Implementations§
Source§impl Clone for SolveStats
impl Clone for SolveStats
Source§fn clone(&self) -> SolveStats
fn clone(&self) -> SolveStats
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more