library(tidyverse)


read_csv("garage-v0.7.csv") %>% add_column(daemon="garage 0.7.3") -> a
read_csv("garage-v0.8.csv") %>% add_column(daemon="garage 0.8.0 beta") -> b
read_csv("minio-20220917.csv") %>% add_column(daemon="minio RELEASE.2022-09-17") -> c
bind_rows(a,b,c) %>% mutate(ms = nanoseconds / 1000 / 1000) -> d

ggplot(d, aes(y = ms, group = daemon, fill=daemon)) +
  #geom_violin(trim = TRUE, width=2) + 
  geom_histogram(binwidth=50, color="black") +
  scale_y_continuous(expand=c(0,0))+
  scale_x_continuous(expand=c(0,0))+
  coord_flip() + 
  labs(
    y="TTFB (ms)",
    x="Count",
    fill="Daemon",
    caption="Get the code to reproduce this graph at https://git.deuxfleurs.fr/Deuxfleurs/mknet",
    title="TTFB (Time To First Byte) on GetObject over a slow network (5 Mbps, 500 µs)",
    subtitle="A 1MB file is uploaded and then fetched 60 times.\nExcept for Minio, the queried node does not store any data (gateway) to force net. communications.") +
  theme_classic() +
  theme(legend.position = c(.15, .8))

ggsave("./plot.png", width=200, height=110, units="mm")
