aboutsummaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorBrendan Ashworth <brendan.ashworth@me.com>2015-02-09 20:25:47 -0800
committerBrendan Ashworth <brendan.ashworth@me.com>2015-03-16 21:26:05 -0700
commit97d8d4928d8126745d7734d635679ccf3c2dd431 (patch)
tree1206ca3998404cc492802bafbce4198cb361355f /benchmark
parent22793da485517845c028df6f46ed1767cf8bb941 (diff)
downloadandroid-node-v8-97d8d4928d8126745d7734d635679ccf3c2dd431.tar.gz
android-node-v8-97d8d4928d8126745d7734d635679ccf3c2dd431.tar.bz2
android-node-v8-97d8d4928d8126745d7734d635679ccf3c2dd431.zip
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: https://github.com/iojs/io.js/pull/777 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'benchmark')
-rwxr-xr-xbenchmark/plot_csv.R38
1 files changed, 38 insertions, 0 deletions
diff --git a/benchmark/plot_csv.R b/benchmark/plot_csv.R
new file mode 100755
index 0000000000..20ab033ef9
--- /dev/null
+++ b/benchmark/plot_csv.R
@@ -0,0 +1,38 @@
+#!/usr/bin/env Rscript
+
+# To use this to graph some benchmarks, install R (http://www.r-project.org/)
+# and ggplot (http://ggplot2.org/).
+#
+# Once installed, you can generate some CSV output with a command like this:
+#
+# $ OUTPUT_FORMAT=csv iojs benchmark/http/client-request-body.js > data.csv
+# $ ./benchmark/plot_csv.R data.csv data.png bytes type
+#
+# Where the 3rd argument to this script is the graph's X coordinate, the 4th is
+# how the output is grouped, and the Y coordinate defaults to result.
+
+library(methods)
+library(ggplot2)
+
+# get info from arguments
+args <- commandArgs(TRUE)
+
+csvFilename <- args[1]
+graphFilename <- args[2]
+
+xCoordinate <- args[3]
+groupBy <- args[4]
+
+# read data
+data <- read.csv(file = csvFilename, head = TRUE)
+
+# plot and save
+plot <- ggplot(data = data, aes_string(x = xCoordinate, y = 'result', col = groupBy)) +
+ geom_point(size = 5) +
+ ggtitle(data$filename)
+
+png(filename = graphFilename, width = 560, height = 480, units = 'px')
+print(plot)
+graphics.off()
+
+cat(paste('Saved to', graphFilename, '\n'))