pub struct BaselineMetrics { /* private fields */ }Expand description
Helper for creating and tracking common “baseline” metrics for each operator
Example:
use datafusion_physical_plan::metrics::{BaselineMetrics, ExecutionPlanMetricsSet};
let metrics = ExecutionPlanMetricsSet::new();
let partition = 2;
let baseline_metrics = BaselineMetrics::new(&metrics, partition);
// during execution, in CPU intensive operation:
let timer = baseline_metrics.elapsed_compute().timer();
// .. do CPU intensive work
timer.done();
// when operator is finished:
baseline_metrics.done();Implementations§
Source§impl BaselineMetrics
impl BaselineMetrics
Sourcepub fn new(metrics: &ExecutionPlanMetricsSet, partition: usize) -> Self
pub fn new(metrics: &ExecutionPlanMetricsSet, partition: usize) -> Self
Create a new BaselineMetric structure, and set start_time to now
Sourcepub fn intermediate(&self) -> BaselineMetrics
pub fn intermediate(&self) -> BaselineMetrics
Returns a BaselineMetrics that updates the same elapsed_compute ignoring
all other metrics
This is useful when an operator offloads some of its intermediate work to separate tasks
that as a result won’t be recorded by Self::record_poll
Sourcepub fn elapsed_compute(&self) -> &Time
pub fn elapsed_compute(&self) -> &Time
return the metric for cpu time spend in this operator
Sourcepub fn output_rows(&self) -> &Count
pub fn output_rows(&self) -> &Count
return the metric for the total number of output rows produced
Sourcepub fn done(&self)
pub fn done(&self)
Records the fact that this operator’s execution is complete
(recording the end_time metric).
Note care should be taken to call done() manually if
BaselineMetrics is not dropped immediately upon operator
completion, as async streams may not be dropped immediately
depending on the consumer.
Sourcepub fn record_output(&self, num_rows: usize)
pub fn record_output(&self, num_rows: usize)
Record that some number of rows have been produced as output
See the RecordOutput for conveniently recording record
batch output for other thing
Sourcepub fn record_poll(
&self,
poll: Poll<Option<Result<RecordBatch>>>,
) -> Poll<Option<Result<RecordBatch>>>
pub fn record_poll( &self, poll: Poll<Option<Result<RecordBatch>>>, ) -> Poll<Option<Result<RecordBatch>>>
Process a poll result of a stream producing output for an operator.
Note: this method only updates output_rows and end_time metrics.
Remember to update elapsed_compute and other metrics manually.
Trait Implementations§
Source§impl Clone for BaselineMetrics
impl Clone for BaselineMetrics
Source§fn clone(&self) -> BaselineMetrics
fn clone(&self) -> BaselineMetrics
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BaselineMetrics
impl Debug for BaselineMetrics
Auto Trait Implementations§
impl Freeze for BaselineMetrics
impl !RefUnwindSafe for BaselineMetrics
impl Send for BaselineMetrics
impl Sync for BaselineMetrics
impl Unpin for BaselineMetrics
impl !UnwindSafe for BaselineMetrics
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§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