-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.R
53 lines (44 loc) · 1.08 KB
/
benchmark.R
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
library(heumilkr)
library(purrr)
library(dplyr)
library(tidyr)
sha <- system("git rev-parse HEAD", intern=TRUE)
set.seed(42)
demand <- runif(500, 5, 15)
pos <-
data.frame(
pos_x = c(0, runif(length(demand), -10, 10)),
pos_y = c(0, runif(length(demand), -10, 10))
)
vehicles <- data.frame(n = NA_integer_, caps = 33)
result <-
do.call(
rbind,
map(
# seq(1, 10000, length.out = 2),
seq(10, 500, by = 20),
function(n) {
demand <- demand[1:n]
distances <- dist(pos[1:(n + 1), ])
bench::mark(
clarke_wright(demand, distances, vehicles)
) |>
rowwise() |>
mutate(
std = sd(time),
mean = mean(time),
n = !!n
) |>
ungroup() |>
select(n, median, mem_alloc, mean, std)
},
.progress = TRUE
)
) |>
mutate(
timestamp = Sys.time(),
sha = !!sha
)
filename <- paste0(format(Sys.time(), "%Y%m%d"), "-", sha, ".rds")
writeLines(filename, "./benchmark/last_result.txt")
saveRDS(result, paste0("./benchmark/", filename))