1+ use offroad:: prelude:: * ;
12use std:: time:: Instant ;
23use togo:: { poly:: arcline200, prelude:: * } ;
3- use offroad:: prelude:: * ;
44
55fn main ( ) {
66 println ! ( "Multi-Offset Benchmark (~200 arcs in double spiral)" ) ;
77 println ! ( "======================================================" ) ;
8-
8+
99 let mut cfg = OffsetCfg :: default ( ) ;
1010 cfg. svg_orig = false ;
1111 let arc_orig = arcline200 ( ) ;
12-
12+
1313 let start = Instant :: now ( ) ;
14-
15- // Forward direction
16- for i in 1 ..100 {
17- offset_arcline_to_arcline ( & arc_orig, ( i as f64 ) /4.0 , & mut cfg) ;
18- }
19-
20- // Reverse direction
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) ;
14+
15+ for _ in 0 ..10 {
16+ // Forward direction
17+ for i in 1 ..100 {
18+ offset_arcline_to_arcline ( & arc_orig, ( i as f64 ) / 4.0 , & mut cfg) ;
19+ }
20+
21+ // Reverse direction
22+ let arcs_reversed = arcline_reverse ( & arc_orig) ;
23+ for i in 1 ..100 {
24+ offset_arcline_to_arcline ( & arcs_reversed, ( i as f64 ) / 4.0 , & mut cfg) ;
25+ }
2426 }
25-
27+
2628 let total_time = start. elapsed ( ) ;
27- let operations = 99 * 2 ; // 99 offsets in each direction
29+ let operations = 10 * 99 * 2 ; // 99 offsets in each direction
2830 let avg_per_operation = total_time / operations;
29-
30- println ! ( "Total time for {} offset operations: {:?}" , operations, total_time) ;
31+
32+ println ! (
33+ "Total time for {} offset operations: {:?}" ,
34+ operations, total_time
35+ ) ;
3136 println ! ( "Average time per operation: {:?}" , avg_per_operation) ;
32- println ! ( "Operations per second: {:.1}" , 1.0 / avg_per_operation. as_secs_f64( ) ) ;
37+ println ! (
38+ "Operations per second: {:.1}" ,
39+ 1.0 / avg_per_operation. as_secs_f64( )
40+ ) ;
3341}
3442
3543/*
@@ -55,4 +63,15 @@ Total time for 198 offset operations: 1.207932511s
5563Average time per operation: 6.100669ms
5664Operations per second: 163.9
5765
66+ The calculation is now repeated 10 times.
67+
68+ AABB v0.5:
69+ Total time for 1980 offset operations: 12.071528916s
70+ Average time per operation: 6.096731ms
71+ Operations per second: 164.0
72+
73+
74+
75+
76+
5877*/
0 commit comments