fix(freq_count): change benchmark to compare single threaded to others
authorMA Beaudet <ma@beaudet.xyz>
Sun, 14 Nov 2021 20:45:15 +0000 (21:45 +0100)
committerMA Beaudet <ma@beaudet.xyz>
Sun, 14 Nov 2021 20:45:15 +0000 (21:45 +0100)
examples/freq_count.rs

index 91ae6c8..f77bcf4 100644 (file)
@@ -11,15 +11,9 @@ fn main() {
 
     let start = Instant::now();
 
-    #[cfg(not(feature = "parallel"))]
     println!("Frequency count for all five-hand poker hands");
     let freq = deck_freq_evaluator(&deck);
 
-    #[cfg(feature = "parallel")]
-    println!("Concurrent frequency count for all five-hand poker hands using rayon");
-    #[cfg(feature = "parallel")]
-    let freq = concurrent_deck_freq_evaluator(&deck);
-
     let duration = start.elapsed();
 
     for i in 1..=9 {
@@ -36,8 +30,15 @@ fn main() {
     println!();
 
     let start = Instant::now();
+    #[cfg(not(feature = "rayon"))]
     println!("Concurrent frequency count for all five-hand poker hands");
+    #[cfg(not(feature = "rayon"))]
     let freq = parallel_deck_freq_evaluator(&deck);
+    #[cfg(feature = "rayon")]
+    println!("Concurrent frequency count for all five-hand poker hands using rayon");
+    #[cfg(feature = "rayon")]
+    let freq = concurrent_deck_freq_evaluator(&deck);
+
     let duration = start.elapsed();
 
     for i in 1..=9 {