src: move debug agent from deps/ to src/
[platform/upstream/nodejs.git] / benchmark / plot.R
1 #!/usr/bin/env Rscript
2
3 # To use this script you'll need to install R: http://www.r-project.org/
4 # and a library for R called ggplot2 
5 # Which can be done by starting R and typing install.packages("ggplot2")
6 # like this:
7 #
8 #     shell% R
9 #     R version 2.11.0 beta (2010-04-12 r51689)
10 #     >  install.packages("ggplot2")
11 #     (follow prompt) 
12 #
13 # Then you can try this script by providing a full path to .data file
14 # outputed from 'make bench'
15 #
16 #     > cd ~/src/node
17 #     > make bench
18 #     ...
19 #     > ./benchmark/plot.R .benchmark_reports/ab-hello-world-buffer-1024/ff456b38862de3fd0118c6ac6b3f46edb1fbb87f/20101013162056.data
20 #     
21 # This will generate a PNG file which you can view
22 #
23 #
24 # Hopefully these steps will be automated in the future.
25
26
27
28 library(ggplot2)
29
30 args <- commandArgs(TRUE)
31
32 ab.load <- function (filename, name) {
33   raw <- data.frame(read.csv(filename, sep="\t", header=T), server=name)
34   raw <- data.frame(raw, time=raw$seconds-min(raw$seconds))
35   raw <- data.frame(raw, time_s=raw$time/1000000)
36   raw
37 }
38
39 #ab.tsPoint <- function (d) {
40 #  qplot(time_s, ttime, data=d, facets=server~.,
41 #        geom="point", alpha=I(1/15), ylab="response time (ms)",
42 #        xlab="time (s)", main="c=30, res=26kb", 
43 #        ylim=c(0,100))
44 #}
45 #
46 #ab.tsLine <- function (d) {
47 #  qplot(time_s, ttime, data=d, facets=server~.,
48 #        geom="line", ylab="response time (ms)",
49 #        xlab="time (s)", main="c=30, res=26kb", 
50 #        ylim=c(0,100))
51 #}
52
53
54 filename <- args[0:1]
55 data <- ab.load(filename, "node")
56
57
58 # histogram
59
60 #hist_png_filename <- gsub(".data", "_hist.png", filename)
61 hist_png_filename <- "hist.png"
62
63 png(filename = hist_png_filename, width = 480, height = 380, units = "px")
64
65 qplot(ttime, data=data, geom="histogram",
66       main="xxx",
67       binwidth=1, xlab="response time (ms)",
68       xlim=c(0,100))
69
70 print(hist_png_filename)
71
72
73
74 # time series
75
76 #ts_png_filename <- gsub(".data", "_ts.png", filename)
77 ts_png_filename = "ts.png"
78
79 png(filename = ts_png_filename, width = 480, height = 380, units = "px")
80
81 qplot(time, ttime, data=data, facets=server~.,
82       geom="point", alpha=I(1/15), ylab="response time (ms)",
83       xlab="time (s)", main="xxx",
84       ylim=c(0,100))
85
86 print(ts_png_filename)