using BenchmarkTools
using SpanningTreeCoverage
Select area to be used for the benchmark:
area = read_area("pillars");
Benchmark the method solve
, which solves the whole the single-robot Coverage Path Planning (CPP) problem:
@benchmark solve($area)
BenchmarkTools.Trial: 945 samples with 1 evaluation. Range (min … max): 4.875 ms … 7.032 ms ┊ GC (min … max): 0.00% … 0.00% Time (median): 5.150 ms ┊ GC (median): 0.00% Time (mean ± σ): 5.152 ms ± 154.687 μs ┊ GC (mean ± σ): 0.00% ± 0.00% ▂▂▂█▅▃▄▅▄▃▂ ▂▃▃▄▃▃▃▃▅▅▇▆▄▆▆▇▅▆████████████████▇▇▆█▄▄▃▃▄▃▂▂▂▂▃▂▂▁▁▁▁▂▁▂▂ ▄ 4.87 ms Histogram: frequency by time 5.5 ms < Memory estimate: 3.37 MiB, allocs estimate: 9222.
Benchmarks of the individual methods called by solve
are shown below.
new_area = subdivide_area(area)
@benchmark subdivide_area($area)
BenchmarkTools.Trial: 10000 samples with 1 evaluation. Range (min … max): 11.910 μs … 1.547 ms ┊ GC (min … max): 0.00% … 97.18% Time (median): 13.394 μs ┊ GC (median): 0.00% Time (mean ± σ): 15.017 μs ± 42.296 μs ┊ GC (mean ± σ): 7.81% ± 2.75% ▂▄▅▅▇██▇▅▃▂ ▂ █████████████▇▆▇▆▃▄▃▅▄▃▃▄▃▁▃▃▅▅▇▇█▇█▇▇▇▇▆▆▆▅▁▁▃▁▃▁▄▅▄▅▅▅▆▇▇ █ 11.9 μs Histogram: log(frequency) by time 26.6 μs < Memory estimate: 38.66 KiB, allocs estimate: 14.
obstacle_nodes = calculate_obstacle_nodes(area)
@benchmark calculate_obstacle_nodes($area)
BenchmarkTools.Trial: 10000 samples with 8 evaluations. Range (min … max): 3.603 μs … 125.653 μs ┊ GC (min … max): 0.00% … 92.73% Time (median): 3.968 μs ┊ GC (median): 0.00% Time (mean ± σ): 4.383 μs ± 5.570 μs ┊ GC (mean ± σ): 7.06% ± 5.38% ▁▄▆██▄▂ ▂ █████████▆▃▅▁▃▃▄▁▄▆▆▇██▇▆▆▆▁▁▃▄▁▄▁▁▁▁▁▄▄▄▅▅▇▅▆▅▄▃▄▃▃▄▄▄▅▄▆▆ █ 3.6 μs Histogram: log(frequency) by time 9.15 μs < Memory estimate: 21.77 KiB, allocs estimate: 7.
mst = calculate_mst(size(area), obstacle_nodes)
@benchmark calculate_mst($size(area), $obstacle_nodes)
BenchmarkTools.Trial: 7033 samples with 1 evaluation. Range (min … max): 531.963 μs … 6.043 ms ┊ GC (min … max): 0.00% … 83.91% Time (median): 599.780 μs ┊ GC (median): 0.00% Time (mean ± σ): 708.606 μs ± 564.115 μs ┊ GC (mean ± σ): 12.11% ± 12.86% ██▆▄▂ ▁ █████▆▅▄▆█▅▆▃▄▁▃▃▁▁▁▁▁▁▁▁▁▁▁▁▁▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▆███ █ 532 μs Histogram: log(frequency) by time 4.27 ms < Memory estimate: 1.15 MiB, allocs estimate: 9143.
guide = calculate_guide(size(area), obstacle_nodes, mst)
@benchmark calculate_guide($size(area), $obstacle_nodes, $mst)
BenchmarkTools.Trial: 1477 samples with 1 evaluation. Range (min … max): 3.183 ms … 5.797 ms ┊ GC (min … max): 0.00% … 39.17% Time (median): 3.340 ms ┊ GC (median): 0.00% Time (mean ± σ): 3.384 ms ± 210.870 μs ┊ GC (mean ± σ): 0.71% ± 3.35% █▅▇▃▂▃▆▆▆▃▂ ▃▃███████████▇▅▅▄▃▂▃▃▃▃▃▃▃▃▃▂▃▂▂▂▃▂▂▂▂▂▁▂▂▁▂▁▂▁▂▂▃▂▂▂▂▂▂▂▂▂ ▃ 3.18 ms Histogram: frequency by time 4.24 ms < Memory estimate: 1.52 MiB, allocs estimate: 46.
path = calculate_circumnavigation_path(new_area, guide)
@benchmark calculate_circumnavigation_path($new_area, $guide)
BenchmarkTools.Trial: 4495 samples with 1 evaluation. Range (min … max): 1.008 ms … 3.338 ms ┊ GC (min … max): 0.00% … 0.00% Time (median): 1.087 ms ┊ GC (median): 0.00% Time (mean ± σ): 1.110 ms ± 101.133 μs ┊ GC (mean ± σ): 0.76% ± 4.18% ▂█ ▂▂▂▄██▇▆▅▆▄▃▂▂▂▂▂▂▂▂▁▁▂▁▁▁▁▁▂▁▁▁▂▁▂▁▁▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▁▂▂ ▂ 1.01 ms Histogram: frequency by time 1.82 ms < Memory estimate: 659.19 KiB, allocs estimate: 15.