Struct datafusion_physical_plan::metrics::BaselineMetrics
source · 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 drop
ped 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, recording the output rows and stream done time and returning the same poll result
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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