Skip to content

Commit 97d8d49

Browse files
benchmark: add plot_csv R graphing script
This commit adds a graphing script (in R) for graphing the CSV output of a benchmark. It can be run like this: ``` $ OUTPUT_FORMAT=csv iojs benchmark/http/client-request-body.js > data.csv $ ./benchmark/plot_csv.R data.csv graph.png bytes type ``` This will graph the output to `graph.png`, using the output's `bytes` value as X and the result value for each as Y. Output will be grouped by `type`. Running as the example yields a beautiful graph like this: http://pbrd.co/1vBhUfy. PR-URL: #777 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 22793da commit 97d8d49

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

benchmark/plot_csv.R

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env Rscript
2+
3+
# To use this to graph some benchmarks, install R (http://www.r-project.org/)
4+
# and ggplot (http://ggplot2.org/).
5+
#
6+
# Once installed, you can generate some CSV output with a command like this:
7+
#
8+
# $ OUTPUT_FORMAT=csv iojs benchmark/http/client-request-body.js > data.csv
9+
# $ ./benchmark/plot_csv.R data.csv data.png bytes type
10+
#
11+
# Where the 3rd argument to this script is the graph's X coordinate, the 4th is
12+
# how the output is grouped, and the Y coordinate defaults to result.
13+
14+
library(methods)
15+
library(ggplot2)
16+
17+
# get info from arguments
18+
args <- commandArgs(TRUE)
19+
20+
csvFilename <- args[1]
21+
graphFilename <- args[2]
22+
23+
xCoordinate <- args[3]
24+
groupBy <- args[4]
25+
26+
# read data
27+
data <- read.csv(file = csvFilename, head = TRUE)
28+
29+
# plot and save
30+
plot <- ggplot(data = data, aes_string(x = xCoordinate, y = 'result', col = groupBy)) +
31+
geom_point(size = 5) +
32+
ggtitle(data$filename)
33+
34+
png(filename = graphFilename, width = 560, height = 480, units = 'px')
35+
print(plot)
36+
graphics.off()
37+
38+
cat(paste('Saved to', graphFilename, '\n'))

0 commit comments

Comments
 (0)