Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env Rscript
- library(ggplot2)
- library(reshape2)
- library(pander)
- data <- read.csv("results/results.csv", check.names=FALSE)
- # Reorder columns for readability.
- col_order <- c("Least-squares slope", "Theil-Sen slope",
- "Mean", "Median of means",
- "Minimum of means", "Quartile 1 of means", "Quartile 3 of means")
- data <- data[, col_order]
- molten <- melt(data)
- # Assign categories to variables.
- molten$type <- factor(
- "This should never be visible",
- levels=c("Central tendency", "Regression", "Other", "This should never be visible"))
- molten <- within(molten, type[variable == "Least-squares slope" | variable == "Theil-Sen slope"] <- "Regression")
- molten <- within(molten, type[variable == "Mean" | variable == "Median of means"] <- "Central tendency")
- molten <- within(molten, type[variable == "Quartile 1 of means" | variable == "Quartile 3 of means" | variable == "Minimum of means"] <- "Other")
- # Draw densities.
- plot <- ggplot(molten, aes(x=value, color=variable)) +
- geom_density(adjust=0.5) +
- labs(x="Time [s]", y="Number of benchmarks (smoothed)", color="") +
- facet_wrap("type", scales="fixed", ncol=1)
- ggsave("results/density.pdf", plot, device=cairo_pdf, width=8, height=6)
- # Draw boxplots.
- plot <- ggplot(molten, aes(x=variable, y=value)) +
- geom_boxplot() +
- labs(x="Statistic", y="Time [s]") +
- theme(axis.text.x=element_text(angle=25, hjust=1))
- png(filename="results/boxplot.png", type="cairo", width=1100, height=1100, units="px", res=200)
- print(plot)
- dev.off()
- # Data range as a single number (instead of vector of min and max).
- range_num <- function(data) {
- return(diff(range(data)))
- }
- # Summarize the spread of the data in a table.
- df <- data.frame()
- df[ncol(data),] <- NA
- rownames(df) <- names(data)
- iqr_rel <- apply(data, 2, IQR) / apply(data, 2, median)
- df$`IQR/Median` <- sprintf("%.1f%%", unlist(iqr_rel * 100))
- range_rel <- apply(data, 2, range_num) / apply(data, 2, median)
- df$`Range/Median` <- sprintf("%.1f%%", unlist(range_rel * 100))
- table <- pandoc.table.return(
- df, style="rmarkdown", justify=c("right", "left", "left"), emphasize.rownames=FALSE)
- handle <- file("results/summary.md")
- writeLines(table, handle)
- close(handle)
Add Comment
Please, Sign In to add comment