Skip to content

Instantly share code, notes, and snippets.

@bbenno
Created April 29, 2021 18:03
Show Gist options
  • Save bbenno/f3bc9c46cd2d47d6e93c4aadfa984aff to your computer and use it in GitHub Desktop.
Save bbenno/f3bc9c46cd2d47d6e93c4aadfa984aff to your computer and use it in GitHub Desktop.
base.json Visualisation
library(tidyverse)
library(jsonlite)
library(here)
save_plot <- function(...) ggsave(width = 7, height = 5, ...)
data <- here("base.json") %>%
fromJSON() %>%
`[[`("thread") %>%
map2(names(.), function(thread, thr_name) {
thread[["histogram"]] %>%
bind_rows() %>%
pivot_longer(everything(), names_to = "timing") %>%
add_column(thread = thr_name)
}) %>%
bind_rows() %>%
mutate(
timing = as.numeric(timing),
value = as.numeric(value),
thread = as.numeric(thread) %>% as.factor()
)
data %>%
ggplot(aes(x = timing)) +
geom_histogram(bins = 100) +
labs(#title = "Histogram",
x = "Time",
y = "Count")
save_plot("histogram_values.pdf")
data %>%
ggplot(aes(x = thread, y = value)) +
geom_boxplot() +
labs(title = "Count Distribution per Thread",
x = "Thread",
y = "Count")
save_plot("distribution_per_thread.pdf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment