Merges George changes
[p2p-testing-infrastructure.git] / TestSpecs / test-scenario-pre-post-nop-ul.r
1 #
2 # Copyright: George Milescu 2010 - george.milescu@gmail.com
3 #
4 # R script used to plot the results of a scenario
5
6 # import ggplot2
7 library(ggplot2)
8
9 # Read transmitted command line arguments
10 args <- commandArgs(trailingOnly = TRUE)
11
12 # The data files are located in the target folder. Also, the graph will be saved in the target folder.
13 target_folder <- args[2]
14 campaign_name <- args[3]
15 rm(args)
16
17 # read data from the data file
18 seeder=read.table(paste(target_folder, "p2p-next-08-103.log.data", sep="/"), header=T, sep=" ")
19 leecher=read.table(paste(target_folder, "p2p-next-08-105.log.data", sep="/"), header=T, sep=" ")
20
21
22 # transform KB/s to Mbit/s
23 leecher$dlspeed <- leecher$dlspeed*8/1000
24
25
26 # plot dlspeed-percent data
27 p <- ggplot() + 
28 geom_point(aes(x=leecher$percent, y=leecher$dlspeed, label="Leecher"), size=1) +
29 theme_bw() +
30 scale_x_continuous("Percent", limits=c(0, 100), breaks=seq(0, 100, 10)) +
31 scale_y_continuous("Download speed (Mbit/s)", limits=c(0, 8), breaks=seq(0, 8, 0.5)) +
32 coord_cartesian() +
33 scale_colour_manual("Legend") +
34 opts(title=paste(campaign_name, "test-scenario-pre-post-nop: a test swarm (1 Seeder, 1 Leecher), all peers have an 8 Mbit/s BW (upload-only)", sep="\n"))
35
36 # plot data as an eps file
37 postscript(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-percent.eps", sep="/"))
38 print(p)
39 dev.off()
40
41 # plot data as an png file
42 png(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-percent.png", sep="/"), width = 1280, height = 800)
43 print(p)
44 dev.off()
45
46
47
48 # plot dlspeed-time data
49 p <- ggplot() + 
50 geom_point(aes(x=leecher$time, y=leecher$dlspeed, label="Leecher"), size=1) +
51 theme_bw() +
52 scale_x_continuous("Time(s)") +
53 scale_y_continuous("Download speed (Mbit/s)", limits=c(0, 8), breaks=seq(0, 8, 0.5)) +
54 coord_cartesian() +
55 scale_colour_manual("Legend") +
56 opts(title=paste(campaign_name, "test-scenario-pre-post-nop: a test swarm (1 Seeder, 1 Leecher), all peers have an 8 Mbit/s BW upload-only", sep="\n"))
57
58 # plot data as an eps file
59 postscript(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-time.eps", sep="/"))
60 print(p)
61 dev.off()
62
63 # plot data as an png file
64 png(paste(target_folder, "test-scenario-pre-post-nop-dlspeed-time.png", sep="/"), width = 1280, height = 800)
65 print(p)
66 dev.off()