pub struct TestScheduler {
pub duration_history: HashMap<String, Vec<u64>>,
pub default_duration_ms: u64,
}Expand description
Scheduler for ordering tests based on duration estimates.
Strategy: Schedule longest tests first (LPT - Longest Processing Time). This helps minimize total execution time by ensuring slow tests start early while faster tests fill in gaps.
Fields§
§duration_history: HashMap<String, Vec<u64>>Duration history for each test (node_id -> list of durations in ms)
default_duration_ms: u64Default duration estimate in ms when no history exists
Implementations§
Source§impl TestScheduler
impl TestScheduler
Sourcepub fn update_duration(&mut self, node_id: &str, duration_ms: u64)
pub fn update_duration(&mut self, node_id: &str, duration_ms: u64)
Update duration history for a test.
Sourcepub fn get_estimated_duration(&self, node_id: &str) -> u64
pub fn get_estimated_duration(&self, node_id: &str) -> u64
Get estimated duration for a test.
Sourcepub fn schedule(
&self,
node_ids: &[String],
failed_first: bool,
recent_failures: &[String],
) -> Vec<String>
pub fn schedule( &self, node_ids: &[String], failed_first: bool, recent_failures: &[String], ) -> Vec<String>
Schedule tests for optimal execution order.
Args: node_ids: Tests to schedule. failed_first: If true, prioritize recently failed tests. recent_failures: List of node IDs that failed recently.
Returns: Ordered list of node IDs optimized for parallel execution.
Sourcepub fn split_balanced(
&self,
node_ids: &[String],
worker_count: usize,
) -> Vec<Vec<String>>
pub fn split_balanced( &self, node_ids: &[String], worker_count: usize, ) -> Vec<Vec<String>>
Split tests into N balanced batches using LPT (Longest Processing Time) algorithm.
This distributes tests across workers to minimize total execution time by:
- Sorting tests by estimated duration (longest first)
- Greedily assigning each test to the batch with the lowest total duration
Returns a vector of batches, where each batch is a vector of node IDs.
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear duration history.
Sourcepub fn tracked_count(&self) -> usize
pub fn tracked_count(&self) -> usize
Get total number of tracked tests.
Trait Implementations§
Source§impl Clone for TestScheduler
impl Clone for TestScheduler
Source§fn clone(&self) -> TestScheduler
fn clone(&self) -> TestScheduler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TestScheduler
impl Debug for TestScheduler
Source§impl Default for TestScheduler
impl Default for TestScheduler
Source§fn default() -> TestScheduler
fn default() -> TestScheduler
Source§impl<'de> Deserialize<'de> for TestScheduler
impl<'de> Deserialize<'de> for TestScheduler
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for TestScheduler
impl RefUnwindSafe for TestScheduler
impl Send for TestScheduler
impl Sync for TestScheduler
impl Unpin for TestScheduler
impl UnsafeUnpin for TestScheduler
impl UnwindSafe for TestScheduler
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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