11use criterion:: { black_box, criterion_group, criterion_main, BenchmarkId , Criterion } ;
2- use phyllotactic_manifold :: * ;
2+ use fractal :: * ;
33
44fn make_seeds ( n : usize ) -> Vec < [ i8 ; 34 ] > {
55 let mut seeds = Vec :: with_capacity ( n) ;
66 for i in 0 ..n {
77 let mut seed = [ 0i8 ; 34 ] ;
88 seed[ 0 ] = ( i % 128 ) as i8 ; // HEEL
99 seed[ 33 ] = ( ( i * 7 ) % 128 ) as i8 ; // GAMMA
10- for j in 1 .. 33 {
11- seed [ j ] = ( ( i * 13 + j * 37 ) % 256 ) as i8 ;
10+ for ( j , slot ) in seed . iter_mut ( ) . enumerate ( ) . take ( 33 ) . skip ( 1 ) {
11+ * slot = ( ( i * 13 + j * 37 ) % 256 ) as i8 ;
1212 }
1313 seeds. push ( seed) ;
1414 }
@@ -59,10 +59,10 @@ fn bench_resonance(c: &mut Criterion) {
5959 let threshold = 1000.0 ;
6060
6161 // Pre-encode
62- let flat8_enc: Vec < _ > = seeds. iter ( ) . map ( |s| flat8:: encode ( s ) ) . collect ( ) ;
63- let spiral8_enc: Vec < _ > = seeds. iter ( ) . map ( |s| spiral8:: encode ( s ) ) . collect ( ) ;
64- let spiral8g_enc: Vec < _ > = seeds. iter ( ) . map ( |s| spiral8_gamma:: encode ( s ) ) . collect ( ) ;
65- let s7p1_enc: Vec < _ > = seeds. iter ( ) . map ( |s| seven_plus_one:: encode ( s ) ) . collect ( ) ;
62+ let flat8_enc: Vec < _ > = seeds. iter ( ) . map ( flat8:: encode) . collect ( ) ;
63+ let spiral8_enc: Vec < _ > = seeds. iter ( ) . map ( spiral8:: encode) . collect ( ) ;
64+ let spiral8g_enc: Vec < _ > = seeds. iter ( ) . map ( spiral8_gamma:: encode) . collect ( ) ;
65+ let s7p1_enc: Vec < _ > = seeds. iter ( ) . map ( seven_plus_one:: encode) . collect ( ) ;
6666
6767 let mut group = c. benchmark_group ( "resonance" ) ;
6868
@@ -85,11 +85,7 @@ fn bench_resonance(c: &mut Criterion) {
8585 group. bench_function ( "spiral8_gamma" , |b| {
8686 b. iter ( || {
8787 for ( x, y) in & spiral8g_enc {
88- black_box ( spiral8_gamma:: resonance (
89- black_box ( x) ,
90- black_box ( y) ,
91- threshold,
92- ) ) ;
88+ black_box ( spiral8_gamma:: resonance ( black_box ( x) , black_box ( y) , threshold) ) ;
9389 }
9490 } )
9591 } ) ;
@@ -107,7 +103,7 @@ fn bench_resonance(c: &mut Criterion) {
107103
108104fn bench_clam48 ( c : & mut Criterion ) {
109105 let seeds = make_seeds ( 1024 ) ;
110- let manifolds: Vec < _ > = seeds. iter ( ) . map ( |s| seven_plus_one:: encode ( s ) ) . collect ( ) ;
106+ let manifolds: Vec < _ > = seeds. iter ( ) . map ( seven_plus_one:: encode) . collect ( ) ;
111107
112108 c. bench_function ( "clam48_extraction" , |b| {
113109 b. iter ( || {
@@ -123,8 +119,8 @@ fn bench_dead_zone(c: &mut Criterion) {
123119 let mut s = [ 0i8 ; 34 ] ;
124120 s[ 0 ] = 42 ;
125121 s[ 33 ] = 7 ;
126- for i in 1 .. 33 {
127- s [ i ] = ( i as i8 ) . wrapping_mul ( 13 ) . wrapping_add ( 37 ) ;
122+ for ( i , slot ) in s . iter_mut ( ) . enumerate ( ) . take ( 33 ) . skip ( 1 ) {
123+ * slot = ( i as i8 ) . wrapping_mul ( 13 ) . wrapping_add ( 37 ) ;
128124 }
129125 s
130126 } ;
@@ -151,12 +147,5 @@ fn bench_encode_scaling(c: &mut Criterion) {
151147 group. finish ( ) ;
152148}
153149
154- criterion_group ! (
155- benches,
156- bench_encode,
157- bench_resonance,
158- bench_clam48,
159- bench_dead_zone,
160- bench_encode_scaling,
161- ) ;
150+ criterion_group ! ( benches, bench_encode, bench_resonance, bench_clam48, bench_dead_zone, bench_encode_scaling, ) ;
162151criterion_main ! ( benches) ;
0 commit comments