Skip to content

Commit

Permalink
add get_history function to Diagnostic (bevyengine#2772)
Browse files Browse the repository at this point in the history
# Objective

- Allow access to diagnostic history value.
- Fixes bevyengine#2771.

## Solution

- Add Diagnostic::get_history function.
  • Loading branch information
Patrick Greene committed Sep 6, 2021
1 parent edd822a commit 18c08dd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/bevy_diagnostic/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ impl Diagnostic {
pub fn get_max_history_length(&self) -> usize {
self.max_history_length
}

pub fn values(&self) -> impl Iterator<Item = &f64> {
self.history.iter().map(|x| &x.value)
}

pub fn measurements(&self) -> impl Iterator<Item = &DiagnosticMeasurement> {
self.history.iter()
}
}

/// A collection of [Diagnostic]s
Expand Down

0 comments on commit 18c08dd

Please sign in to comment.