pub struct RewriterStats {
pub is_optimization_enabled: Option<bool>,
pub rewriter_run_time: Option<Duration>,
pub rewriter_rule_application_attempts: Option<usize>,
pub rewriter_rule_applications: Option<usize>,
}
Expand description
Represents the statistical data collected during the model rewriting process.
The RewriterStats
struct is used to track various metrics and statistics related to the rewriting
of a model using a set of rules. These statistics can be used for performance monitoring, debugging,
and optimization purposes. The structure supports optional fields, allowing selective tracking of data
without requiring all fields to be set.
The struct uses the following features:
#[skip_serializing_none]
: Skips serializing fields that have a value ofNone
, resulting in cleaner JSON output.#[serde(rename_all = "camelCase")]
: Uses camelCase for all serialized field names, adhering to common JSON naming conventions.
§Fields
-
is_optimization_enabled
:- Type:
Option<bool>
- Indicates whether optimizations were enabled during the rewriting process.
- If
Some(true)
, it means optimizations were enabled. - If
Some(false)
, optimizations were explicitly disabled. - If
None
, the status of optimizations is unknown or not tracked.
- Type:
-
rewriter_run_time
:- Type:
Option<std::time::Duration>
- The total runtime duration of the rewriter in the current session.
- If set, it indicates the amount of time spent on rewriting, measured as a
Duration
. - If
None
, the runtime is either unknown or not tracked.
- Type:
-
rewriter_rule_application_attempts
:- Type:
Option<usize>
- The number of rule application attempts made during the rewriting process.
- An attempt is counted each time a rule is evaluated, regardless of whether it was successfully applied.
- If
None
, this metric is not tracked or not applicable for the current session.
- Type:
-
rewriter_rule_applications
:- Type:
Option<usize>
- The number of successful rule applications during the rewriting process.
- A successful application means the rule was successfully applied to transform the expression or constraint.
- If
None
, this metric is not tracked or not applicable for the current session.
- Type:
§Example
let stats = RewriterStats { is_optimization_enabled: Some(true), rewriter_run_time: Some(std::time::Duration::new(2, 0)), rewriter_rule_application_attempts: Some(15), rewriter_rule_applications: Some(10), };
// Serialize the stats to JSON let serialized_stats = serde_json::to_string(&stats).unwrap(); println!(“Serialized Stats: {}”, serialized_stats);
§Usage Notes
- This struct is intended to be used in contexts where tracking the performance and behavior of rule-based rewriting systems is necessary. It is designed to be easily serialized and deserialized to/from JSON, making it suitable for logging, analytics, and reporting purposes.
§See Also
serde_with::skip_serializing_none
: For skippingNone
values during serialization.std::time::Duration
: For measuring and representing time intervals.
Fields§
§is_optimization_enabled: Option<bool>
§rewriter_run_time: Option<Duration>
§rewriter_rule_application_attempts: Option<usize>
§rewriter_rule_applications: Option<usize>
Trait Implementations§
Source§impl Clone for RewriterStats
impl Clone for RewriterStats
Source§fn clone(&self) -> RewriterStats
fn clone(&self) -> RewriterStats
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Default for RewriterStats
impl Default for RewriterStats
Source§fn default() -> RewriterStats
fn default() -> RewriterStats
Source§impl JsonSchema for RewriterStats
impl JsonSchema for RewriterStats
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreAuto Trait Implementations§
impl Freeze for RewriterStats
impl RefUnwindSafe for RewriterStats
impl Send for RewriterStats
impl Sync for RewriterStats
impl Unpin for RewriterStats
impl UnwindSafe for RewriterStats
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more