11cb0ef41Sopenharmony_ci#!/usr/bin/env Rscript 21cb0ef41Sopenharmony_cilibrary(ggplot2); 31cb0ef41Sopenharmony_cilibrary(plyr); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci# get __dirname and load ./_cli.R 61cb0ef41Sopenharmony_ciargs = commandArgs(trailingOnly = F); 71cb0ef41Sopenharmony_cidirname = dirname(sub("--file=", "", args[grep("--file", args)])); 81cb0ef41Sopenharmony_cisource(paste0(dirname, '/_cli.R'), chdir=T); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciif (!is.null(args.options$help) || 111cb0ef41Sopenharmony_ci (!is.null(args.options$plot) && args.options$plot == TRUE)) { 121cb0ef41Sopenharmony_ci stop("usage: cat file.csv | Rscript bar.R 131cb0ef41Sopenharmony_ci --help show this message 141cb0ef41Sopenharmony_ci --plot filename save plot to filename"); 151cb0ef41Sopenharmony_ci} 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciplot.filename = args.options$plot; 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_cidat = read.csv( 201cb0ef41Sopenharmony_ci file('stdin'), 211cb0ef41Sopenharmony_ci colClasses=c('character', 'character', 'character', 'numeric', 'numeric') 221cb0ef41Sopenharmony_ci); 231cb0ef41Sopenharmony_cidat = data.frame(dat); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_cidat$nameTwoLines = paste0(dat$filename, '\n', dat$configuration); 261cb0ef41Sopenharmony_cidat$name = paste0(dat$filename, ' ', dat$configuration); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci# Create a box plot 291cb0ef41Sopenharmony_ciif (!is.null(plot.filename)) { 301cb0ef41Sopenharmony_ci p = ggplot(data=dat, aes(x=nameTwoLines, y=rate, fill=binary)); 311cb0ef41Sopenharmony_ci p = p + geom_bar(stat="summary", position=position_dodge()); 321cb0ef41Sopenharmony_ci p = p + ylab("rate of operations (higher is better)"); 331cb0ef41Sopenharmony_ci p = p + xlab("benchmark"); 341cb0ef41Sopenharmony_ci p = p + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)); 351cb0ef41Sopenharmony_ci ggsave(plot.filename, p); 361cb0ef41Sopenharmony_ci} 37