11use std:: time:: Instant ;
2- use togo:: prelude:: * ;
2+ use togo:: { poly :: arcline200 , prelude:: * } ;
33use offroad:: prelude:: * ;
44
55fn main ( ) {
6- println ! ( "Multi-Offset Benchmark (based on offset_multi example )" ) ;
6+ println ! ( "Multi-Offset Benchmark (~200 arcs in double spiral )" ) ;
77 println ! ( "======================================================" ) ;
88
99 let mut cfg = OffsetCfg :: default ( ) ;
1010 cfg. svg_orig = false ;
11- let poly_orig = pline_01 ( ) [ 0 ] . clone ( ) ;
12- let poly = polyline_translate ( & poly_orig, point ( 250.0 , 100.0 ) ) ;
11+ let arc_orig = arcline200 ( ) ;
1312
1413 let start = Instant :: now ( ) ;
1514
1615 // Forward direction
17- for i in 1 ..500 {
18- offset_polyline_to_polyline ( & poly , ( i as f64 ) /5 .0, & mut cfg) ;
16+ for i in 1 ..100 {
17+ offset_arcline_to_arcline ( & arc_orig , ( i as f64 ) /4 .0, & mut cfg) ;
1918 }
2019
2120 // Reverse direction
22- let poly = polyline_reverse ( & poly ) ;
23- for i in 1 ..500 {
24- offset_polyline_to_polyline ( & poly , ( i as f64 ) /5 .0, & mut cfg) ;
21+ let arcs_reversed = arcline_reverse ( & arc_orig ) ;
22+ for i in 1 ..100 {
23+ offset_arcline_to_arcline ( & arcs_reversed , ( i as f64 ) /4 .0, & mut cfg) ;
2524 }
2625
2726 let total_time = start. elapsed ( ) ;
28- let operations = 149 * 2 ; // 149 offsets in each direction
27+ let operations = 99 * 2 ; // 99 offsets in each direction
2928 let avg_per_operation = total_time / operations;
3029
3130 println ! ( "Total time for {} offset operations: {:?}" , operations, total_time) ;
@@ -34,10 +33,11 @@ fn main() {
3433}
3534
3635/*
37- > cargo bench
36+ > cargo bench --bench bench_offset_multiple200
37+
38+ Total time for 198 offset operations: 3.386764598s
39+ Average time per operation: 17.104871ms
40+ Operations per second: 58.5
3841
39- Total time for 298 offset operations: 196.589137ms
40- Average time per operation: 659.695µs
41- Operations per second: 1515.9
4242
4343*/
0 commit comments