pumpkin_core/statistics/
mod.rs1pub mod moving_averages;
3pub(crate) mod statistic_logger;
4pub(crate) mod statistic_logging;
5
6use std::fmt::Display;
7
8pub use statistic_logger::StatisticLogger;
9pub use statistic_logging::StatisticOptions;
10pub use statistic_logging::configure_statistic_logging;
11pub use statistic_logging::log_statistic;
12pub use statistic_logging::log_statistic_postfix;
13pub use statistic_logging::should_log_statistics;
14
15#[cfg(doc)]
16use crate::Solver;
17#[cfg(doc)]
18use crate::create_statistics_struct;
19
20pub trait Statistic {
24 fn log(&self, statistic_logger: StatisticLogger);
26}
27
28impl<Value: Display> Statistic for Value {
29 fn log(&self, statistic_logger: StatisticLogger) {
30 statistic_logger.log_statistic(self);
31 }
32}
33
34#[macro_export]
48macro_rules! create_statistics_struct {
49 ($(#[$struct_documentation:meta])* $name:ident { $($(#[$variable_documentation:meta])* $field:ident : $type:ident $(< $( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+ >)?),+ $(,)? }) => {
50 $(#[$struct_documentation])*
51 #[derive(Default, Debug, Copy, Clone)]
52 pub(crate) struct $name {
53 $($(#[$variable_documentation])* pub(crate) $field: $type $(< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)?),+
54 }
55
56 impl $crate::statistics::Statistic for $name {
57 fn log(&self, statistic_logger: $crate::statistics::StatisticLogger) {
58 $(self.$field.log(statistic_logger.attach_to_prefix(stringify!($field),)));+
59 }
60 }
61 };
62}