From c80a6dd55a32223e738c108a85f68c25e0cf77e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sun, 1 Aug 2021 06:11:54 +0200 Subject: [PATCH] Draft benchmarking code --- bench/bench.R | 53 +++++++++++++++++++ .../bench.R/rpubs.com/rpubs/Document.dcf | 11 ++++ 2 files changed, 64 insertions(+) create mode 100644 bench/bench.R create mode 100644 bench/rsconnect/documents/bench.R/rpubs.com/rpubs/Document.dcf diff --git a/bench/bench.R b/bench/bench.R new file mode 100644 index 000000000..b3ff598a8 --- /dev/null +++ b/bench/bench.R @@ -0,0 +1,53 @@ +library(tidyverse) + +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() diff --git a/bench/rsconnect/documents/bench.R/rpubs.com/rpubs/Document.dcf b/bench/rsconnect/documents/bench.R/rpubs.com/rpubs/Document.dcf new file mode 100644 index 000000000..198fd8afd --- /dev/null +++ b/bench/rsconnect/documents/bench.R/rpubs.com/rpubs/Document.dcf @@ -0,0 +1,11 @@ +name: Document +title: +username: +account: rpubs +server: rpubs.com +hostUrl: rpubs.com +appId: https://api.rpubs.com/api/v1/document/795229/b42d9bbdb0444025b33bfac592544060 +bundleId: https://api.rpubs.com/api/v1/document/795229/b42d9bbdb0444025b33bfac592544060 +url: http://rpubs.com/publish/claim/795229/c215a9faa0fd4ac5947aeb8b8cfeaa56 +when: 1627788578.75794 +lastSyncTime: 1627788578.75796