-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbench_offset_multiple1000.rs
More file actions
49 lines (38 loc) · 1.48 KB
/
bench_offset_multiple1000.rs
File metadata and controls
49 lines (38 loc) · 1.48 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
use std::time::Instant;
use togo::{poly::arcline1000, prelude::*};
use offroad::prelude::*;
fn main() {
println!("Multi-Offset Benchmark (~1000 arcs in double spiral)");
println!("======================================================");
let mut cfg = OffsetCfg::default();
cfg.svg_orig = false;
let arc_orig = arcline1000();
let start = Instant::now();
// Forward direction
for i in 1..26 {
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..26 {
offset_arcline_to_arcline(&arcs_reversed, (i as f64)/4.0, &mut cfg);
}
let total_time = start.elapsed();
let operations = 25 * 2; // 25 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_multiple1000
BRUTE-FORCE (USE_BRUTE_FORCE = true):
Total time for 50 offset operations: 19.007039989s
Average time per operation: 380.140799ms
Operations per second: 2.6
SPATIAL INDEX (USE_BRUTE_FORCE = false):
Total time for 50 offset operations: 6.249249758s
Average time per operation: 124.984995ms
Operations per second: 8.0
SPEEDUP: 3.04x faster with spatial index
*/