-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to run stress for a finite duration or count
- Loading branch information
1 parent
2a03a5c
commit 1a48cd2
Showing
8 changed files
with
662 additions
and
354 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,38 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use std::str::FromStr; | ||
|
||
use duration_str::parse; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub mod bench_driver; | ||
pub mod driver; | ||
|
||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)] | ||
pub enum Interval { | ||
Count(u64), | ||
Time(tokio::time::Duration), | ||
} | ||
|
||
impl Interval { | ||
pub fn is_unbounded(&self) -> bool { | ||
matches!(self, Interval::Time(tokio::time::Duration::MAX)) | ||
} | ||
} | ||
|
||
impl FromStr for Interval { | ||
type Err = String; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
if let Ok(i) = s.parse() { | ||
Ok(Interval::Count(i)) | ||
} else if let Ok(d) = parse(s) { | ||
Ok(Interval::Time(d)) | ||
} else if "unbounded" == s { | ||
Ok(Interval::Time(tokio::time::Duration::MAX)) | ||
} else { | ||
Err("Required integer number of cycles or time duration".to_string()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.