File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ mod life;
9
9
mod matmul;
10
10
mod mergesort;
11
11
mod nbody;
12
+ mod noop;
12
13
mod quicksort;
13
14
mod sieve;
14
15
mod tsp;
@@ -81,6 +82,7 @@ Benchmarks:
81
82
- sieve: Finding primes using a Sieve of Eratosthenes.
82
83
- matmul: Parallel matrix multiplication.
83
84
- mergesort: Parallel mergesort.
85
+ - noop: Launch empty tasks to measure CPU usage.
84
86
- quicksort: Parallel quicksort.
85
87
- tsp: Traveling salesman problem solver (sample data sets in `data/tsp`).
86
88
" ;
@@ -106,6 +108,7 @@ fn main() {
106
108
"sieve" => sieve:: main ( & args[ 1 ..] ) ,
107
109
"tsp" => tsp:: main ( & args[ 1 ..] ) ,
108
110
"life" => life:: main ( & args[ 1 ..] ) ,
111
+ "noop" => noop:: main ( & args[ 1 ..] ) ,
109
112
_ => usage ( ) ,
110
113
}
111
114
}
Original file line number Diff line number Diff line change
1
+ const USAGE : & str = "
2
+ Usage: noop [--sleep N] [--iters N]
3
+
4
+ Noop loop to measure CPU usage. See rayon-rs/rayon#642.
5
+
6
+ Options:
7
+ --sleep N How long to sleep (in millis) between doing a spawn. [default: 10]
8
+ --iters N Total time to execution (in millis). [default: 100]
9
+ " ;
10
+
11
+ use docopt:: Docopt ;
12
+
13
+ #[ derive( Deserialize ) ]
14
+ pub struct Args {
15
+ flag_sleep : u64 ,
16
+ flag_iters : u64 ,
17
+ }
18
+
19
+ pub fn main ( args : & [ String ] ) {
20
+ let args: Args = Docopt :: new ( USAGE )
21
+ . and_then ( |d| d. argv ( args) . deserialize ( ) )
22
+ . unwrap_or_else ( |e| e. exit ( ) ) ;
23
+
24
+ for _ in 1 ..args. flag_iters {
25
+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( args. flag_sleep ) ) ;
26
+ rayon:: spawn ( move || { } ) ;
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments