File: plot_csv.R

package info (click to toggle)
nodejs 4.8.2~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 62,476 kB
  • ctags: 111,183
  • sloc: cpp: 661,544; ansic: 31,406; python: 23,073; makefile: 1,418; sh: 1,384; perl: 255; lisp: 222; ruby: 76; xml: 50
file content (38 lines) | stat: -rwxr-xr-x 1,065 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 node 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'))