Skip to content

Commit d1f4331

Browse files
RafaelGSSruyadorno
authored andcommittedSep 12, 2023
benchmark: add bar.R
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: #47729 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
1 parent fbe89e6 commit d1f4331

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed
 

‎benchmark/bar.R

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env Rscript
2+
library(ggplot2);
3+
library(plyr);
4+
5+
# get __dirname and load ./_cli.R
6+
args = commandArgs(trailingOnly = F);
7+
dirname = dirname(sub("--file=", "", args[grep("--file", args)]));
8+
source(paste0(dirname, '/_cli.R'), chdir=T);
9+
10+
if (!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+
17+
plot.filename = args.options$plot;
18+
19+
dat = read.csv(
20+
file('stdin'),
21+
colClasses=c('character', 'character', 'character', 'numeric', 'numeric')
22+
);
23+
dat = data.frame(dat);
24+
25+
dat$nameTwoLines = paste0(dat$filename, '\n', dat$configuration);
26+
dat$name = paste0(dat$filename, ' ', dat$configuration);
27+
28+
# Create a box plot
29+
if (!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+
}

‎doc/contributing/writing-and-running-benchmarks.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ module, you can use the `--filter` option:_
293293
```
294294

295295
For analyzing the benchmark results, use [node-benchmark-compare][] or the R
296-
script `benchmark/compare.R`.
296+
scripts:
297+
298+
* `benchmark/compare.R`
299+
* `benchmark/bar.R`
297300

298301
```console
299302
$ node-benchmark-compare compare-pr-5134.csv # or cat compare-pr-5134.csv | Rscript benchmark/compare.R

0 commit comments

Comments
 (0)
Please sign in to comment.