• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env Rscript
2library(ggplot2);
3library(plyr);
4
5# get __dirname and load ./_cli.R
6args = commandArgs(trailingOnly = F);
7dirname = dirname(sub("--file=", "", args[grep("--file", args)]));
8source(paste0(dirname, '/_cli.R'), chdir=T);
9
10if (!is.null(args.options$help) ||
11   (!is.null(args.options$plot) && args.options$plot == TRUE)) {
12  stop("usage: cat file.csv | Rscript bar.R
13  --help           show this message
14  --plot filename  save plot to filename");
15}
16
17plot.filename = args.options$plot;
18
19dat = read.csv(
20  file('stdin'),
21  colClasses=c('character', 'character', 'character', 'numeric', 'numeric')
22);
23dat = data.frame(dat);
24
25dat$nameTwoLines = paste0(dat$filename, '\n', dat$configuration);
26dat$name = paste0(dat$filename, ' ', dat$configuration);
27
28# Create a box plot
29if (!is.null(plot.filename)) {
30  p = ggplot(data=dat, aes(x=nameTwoLines, y=rate, fill=binary));
31  p = p + geom_bar(stat="summary", position=position_dodge());
32  p = p + ylab("rate of operations (higher is better)");
33  p = p + xlab("benchmark");
34  p = p + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5));
35  ggsave(plot.filename, p);
36}
37