11use  criterion:: { black_box,  criterion_group,  criterion_main,  Criterion } ; 
22use  itertools:: free:: cloned; 
3+ use  itertools:: iproduct; 
34use  itertools:: Itertools ; 
4- use  itertools:: Position ; 
5- use  itertools:: { iproduct,  EitherOrBoth } ; 
65
76use  std:: cmp; 
87use  std:: iter:: repeat; 
@@ -391,25 +390,6 @@ fn zip_unchecked_counted_loop3(c: &mut Criterion) {
391390    } ) ; 
392391} 
393392
394- fn  ziplongest ( c :  & mut  Criterion )  { 
395-     let  v1 = black_box ( ( 0 ..768 ) . collect_vec ( ) ) ; 
396-     let  v2 = black_box ( ( 0 ..1024 ) . collect_vec ( ) ) ; 
397-     c. bench_function ( "ziplongest" ,  move  |b| { 
398-         b. iter ( || { 
399-             let  zip = v1. iter ( ) . zip_longest ( v2. iter ( ) ) ; 
400-             let  sum = zip. fold ( 0u32 ,  |mut  acc,  val| { 
401-                 match  val { 
402-                     EitherOrBoth :: Both ( x,  y)  => acc += x *  y, 
403-                     EitherOrBoth :: Left ( x)  => acc += x, 
404-                     EitherOrBoth :: Right ( y)  => acc += y, 
405-                 } 
406-                 acc
407-             } ) ; 
408-             sum
409-         } ) 
410-     } ) ; 
411- } 
412- 
413393fn  group_by_lazy_1 ( c :  & mut  Criterion )  { 
414394    let  mut  data = vec ! [ 0 ;  1024 ] ; 
415395    for  ( index,  elt)  in  data. iter_mut ( ) . enumerate ( )  { 
@@ -448,25 +428,6 @@ fn group_by_lazy_2(c: &mut Criterion) {
448428    } ) ; 
449429} 
450430
451- fn  while_some ( c :  & mut  Criterion )  { 
452-     c. bench_function ( "while_some" ,  |b| { 
453-         b. iter ( || { 
454-             let  data = black_box ( 
455-                 ( 0 ..) 
456-                     . fuse ( ) 
457-                     . map ( |i| std:: char:: from_digit ( i,  16 ) ) 
458-                     . while_some ( ) , 
459-             ) ; 
460-             // let result: String = data.fold(String::new(), |acc, ch| acc + &ch.to_string()); 
461-             let  result = data. fold ( String :: new ( ) ,  |mut  acc,  ch| { 
462-                 acc. push ( ch) ; 
463-                 acc
464-             } ) ; 
465-             assert_eq ! ( result. as_str( ) ,  "0123456789abcdef" ) ; 
466-         } ) ; 
467-     } ) ; 
468- } 
469- 
470431fn  slice_chunks ( c :  & mut  Criterion )  { 
471432    let  data = vec ! [ 0 ;  1024 ] ; 
472433
@@ -703,22 +664,6 @@ fn cartesian_product_iterator(c: &mut Criterion) {
703664    } ) ; 
704665} 
705666
706- fn  cartesian_product_fold ( c :  & mut  Criterion )  { 
707-     let  xs = vec ! [ 0 ;  16 ] ; 
708- 
709-     c. bench_function ( "cartesian product fold" ,  move  |b| { 
710-         b. iter ( || { 
711-             let  mut  sum = 0 ; 
712-             iproduct ! ( & xs,  & xs,  & xs) . fold ( ( ) ,  |( ) ,  ( & x,  & y,  & z) | { 
713-                 sum += x; 
714-                 sum += y; 
715-                 sum += z; 
716-             } ) ; 
717-             sum
718-         } ) 
719-     } ) ; 
720- } 
721- 
722667fn  multi_cartesian_product_iterator ( c :  & mut  Criterion )  { 
723668    let  xs = [ vec ! [ 0 ;  16 ] ,  vec ! [ 0 ;  16 ] ,  vec ! [ 0 ;  16 ] ] ; 
724669
@@ -735,22 +680,6 @@ fn multi_cartesian_product_iterator(c: &mut Criterion) {
735680    } ) ; 
736681} 
737682
738- fn  multi_cartesian_product_fold ( c :  & mut  Criterion )  { 
739-     let  xs = [ vec ! [ 0 ;  16 ] ,  vec ! [ 0 ;  16 ] ,  vec ! [ 0 ;  16 ] ] ; 
740- 
741-     c. bench_function ( "multi cartesian product fold" ,  move  |b| { 
742-         b. iter ( || { 
743-             let  mut  sum = 0 ; 
744-             xs. iter ( ) . multi_cartesian_product ( ) . fold ( ( ) ,  |( ) ,  x| { 
745-                 sum += x[ 0 ] ; 
746-                 sum += x[ 1 ] ; 
747-                 sum += x[ 2 ] ; 
748-             } ) ; 
749-             sum
750-         } ) 
751-     } ) ; 
752- } 
753- 
754683fn  cartesian_product_nested_for ( c :  & mut  Criterion )  { 
755684    let  xs = vec ! [ 0 ;  16 ] ; 
756685
@@ -839,33 +768,6 @@ fn permutations_slice(c: &mut Criterion) {
839768    } ) ; 
840769} 
841770
842- fn  with_position_fold ( c :  & mut  Criterion )  { 
843-     let  v = black_box ( ( 0 ..10240 ) . collect_vec ( ) ) ; 
844-     c. bench_function ( "with_position fold" ,  move  |b| { 
845-         b. iter ( || { 
846-             v. iter ( ) 
847-                 . with_position ( ) 
848-                 . fold ( 0 ,  |acc,  ( pos,  & item) | match  pos { 
849-                     Position :: Middle  => acc + item, 
850-                     Position :: First  => acc - 2  *  item, 
851-                     Position :: Last  => acc + 2  *  item, 
852-                     Position :: Only  => acc + 5  *  item, 
853-                 } ) 
854-         } ) 
855-     } ) ; 
856- } 
857- 
858- fn  tuple_combinations_fold ( c :  & mut  Criterion )  { 
859-     let  v = black_box ( ( 0 ..64 ) . collect_vec ( ) ) ; 
860-     c. bench_function ( "tuple_combinations fold" ,  move  |b| { 
861-         b. iter ( || { 
862-             v. iter ( ) 
863-                 . tuple_combinations ( ) 
864-                 . fold ( 0 ,  |acc,  ( a,  b,  c,  d) | acc + * a *  * c - * b *  * d) 
865-         } ) 
866-     } ) ; 
867- } 
868- 
869771criterion_group ! ( 
870772    benches, 
871773    slice_iter, 
@@ -887,7 +789,6 @@ criterion_group!(
887789    zipdot_i32_unchecked_counted_loop, 
888790    zipdot_f32_unchecked_counted_loop, 
889791    zip_unchecked_counted_loop3, 
890-     ziplongest, 
891792    group_by_lazy_1, 
892793    group_by_lazy_2, 
893794    slice_chunks, 
@@ -903,18 +804,13 @@ criterion_group!(
903804    step_range_2, 
904805    step_range_10, 
905806    cartesian_product_iterator, 
906-     cartesian_product_fold, 
907807    multi_cartesian_product_iterator, 
908-     multi_cartesian_product_fold, 
909808    cartesian_product_nested_for, 
910809    all_equal, 
911810    all_equal_for, 
912811    all_equal_default, 
913812    permutations_iter, 
914813    permutations_range, 
915814    permutations_slice, 
916-     with_position_fold, 
917-     tuple_combinations_fold, 
918-     while_some, 
919815) ; 
920816criterion_main ! ( benches) ; 
0 commit comments