library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.3 ✓ dplyr 1.0.7
## ✓ tidyr 1.1.3 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
follow_first_parent <- function(data) {
out <- character(nrow(data))
current <- data$commit_hash[[1]]
target <- 0
for (i in seq_len(nrow(data))) {
if (data$commit_hash[[i]] == current) {
target <- target + 1
out[[target]] <- current
if (length(data$parent_hashes[[i]]) == 0) {
break
}
current <- data$parent_hashes[[i]][[1]]
}
}
length(out) <- target
return(out)
}
prune_first_parent <- function(data) {
history <- follow_first_parent(data)
pruned <-
data %>%
filter(commit_hash %in% !!history)
pruned %>%
mutate(id = -row_number()) %>%
arrange(id)
}
data <- bench::cb_read()
pruned <-
data %>%
prune_first_parent()
pruned %>%
select(id, abbrev_commit_hash, benchmarks) %>%
unnest(benchmarks) %>%
select(id, abbrev_commit_hash, os, file, name, time, value = p50) %>%
group_by(os, file, name) %>%
mutate(mean_value = mean(value)) %>%
ungroup() %>%
mutate(norm_value = value / mean_value) %>%
ggplot(aes(x = id, y = norm_value, group = name)) %>% +
geom_line() %>% +
facet_wrap(vars(os, file)) %>% +
scale_y_log10() %>%
plotly::ggplotly()
## Warning in dev_fun(file = tempfile(), width = width %||% 640, height = height
## %||% : partial argument match of 'file' to 'filename'