-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6231444
commit 6752b00
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const USAGE: &str = " | ||
Usage: noop [--sleep N] [--iters N] | ||
Noop loop to measure CPU usage. See rayon-rs/rayon#642. | ||
Options: | ||
--sleep N How long to sleep (in millis) between doing a spawn. [default: 10] | ||
--iters N Total time to execution (in millis). [default: 100] | ||
"; | ||
|
||
use docopt::Docopt; | ||
|
||
#[derive(Deserialize)] | ||
pub struct Args { | ||
flag_sleep: u64, | ||
flag_iters: u64, | ||
} | ||
|
||
pub fn main(args: &[String]) { | ||
let args: Args = Docopt::new(USAGE) | ||
.and_then(|d| d.argv(args).deserialize()) | ||
.unwrap_or_else(|e| e.exit()); | ||
|
||
for _ in 1..args.flag_iters { | ||
std::thread::sleep(std::time::Duration::from_millis(args.flag_sleep)); | ||
rayon::spawn(move || { } ); | ||
} | ||
} |