-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbench_offset_multiple500.rs
More file actions
70 lines (57 loc) · 2.22 KB
/
Copy pathbench_offset_multiple500.rs
File metadata and controls
70 lines (57 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use std::time::Instant;
use togo::{poly::arcline500, prelude::*};
use offroad::prelude::*;
fn main() {
println!("Multi-Offset Benchmark (~500 arcs in double spiral)");
println!("======================================================");
let mut cfg = OffsetCfg::default();
cfg.svg_orig = false;
let arc_orig = arcline500();
let start = Instant::now();
// Forward direction
for i in 1..100 {
offset_arcline_to_arcline(&arc_orig, (i as f64)/4.0, &mut cfg);
}
// Reverse direction
let arcs_reversed = arcline_reverse(&arc_orig);
for i in 1..100 {
offset_arcline_to_arcline(&arcs_reversed, (i as f64)/4.0, &mut cfg);
}
let total_time = start.elapsed();
let operations = 99 * 2; // 99 offsets in each direction
let avg_per_operation = total_time / operations;
println!("Total time for {} offset operations: {:?}", operations, total_time);
println!("Average time per operation: {:?}", avg_per_operation);
println!("Operations per second: {:.1}", 1.0 / avg_per_operation.as_secs_f64());
}
/*
>
cargo bench --bench bench_offset_multiple500
BRUTE-FORCE (USE_BRUTE_FORCE = true):
Total time for 198 offset operations: 14.44784818s
Average time per operation: 72.96893ms
Operations per second: 13.7
SPATIAL INDEX (USE_BRUTE_FORCE = false) - polyarcs only:
Total time for 198 offset operations: 5.527450981s
Average time per operation: 27.916419ms
Operations per second: 35.8
AABB v0.3:
Total time for 198 offset operations: 5.513286097s
Average time per operation: 27.844879ms
Operations per second: 35.9
AABB v0.5:
Total time for 198 offset operations: 5.368359789s
Average time per operation: 27.112928ms
Operations per second: 36.9
_______________________________________________________________
Opt 10 - check aabb before split
Total time for 198 offset operations: 3.054654626s
Average time per operation: 15.427548ms
Operations per second: 64.8
_______________________________________________________________
Opt 11 - find_endpoint_groups with spatial index
Total time for 198 offset operations: 2.298718087s
Average time per operation: 11.609687ms
Operations per second: 86.1
_______________________________________________________________
*/