-
Notifications
You must be signed in to change notification settings - Fork 2
/
analysis.R
145 lines (111 loc) · 4.6 KB
/
analysis.R
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
args = commandArgs(trailingOnly=TRUE)
if(length(args)!=2) {
stop("At least two arguments must be supplied (working directory and input file)", call.=FALSE)
} else {
setwd(args[1])
data <- read.csv(args[2], header=TRUE, sep=',', colClasses= c("character","character","character","integer","character","numeric","numeric"),)
}
require("ggplot2")
##############################################################################
#result <- data$result
#rate <- as.data.frame(table(result))
#
#Estado <- c("Erro", "Sucesso")
#theme_set(theme_gray(base_size = 18))
#png('rate.png')
#ggplot(rate, aes(result, Freq, fill=Estado)) + geom_bar(stat="identity", width=.6) +
#xlab("Estado da resposta da requisição") + ylab("Requisições") +
#theme(axis.text.x=element_blank(), axis.ticks.x=element_blank())
#dev.off()
##############################################################################
data['request_sum'] <- 1
data['request_sum'] <- sapply(data['request_sum'], function(x) as.numeric(x))
hours <- c()
val <- min(data$request_time_mili)
interval <- 60000
n <- (max(data$request_time_mili) - min(data$request_time_mili))/interval
for (x in 1:n) {
hours <- c(hours, val)
val <- val + interval
}
time <- aggregate(data$request_sum, list(cut(data$request_time_mili, breaks=hours)), sum)
time$minute <- seq.int(nrow(time))
png('load.png')
ggplot(data=time, aes(x=minute, y=request_sum, group=1)) +
geom_bar(stat="identity", fill="#56B4E9") +
xlab("Experiment Time (min)") + ylab("Perfomed Requests")
dev.off()
##############################################################################
hours <- c()
val <- min(data$response_time_mili)
interval <- 60000
n <- (max(data$response_time_mili) - min(data$response_time_mili))/interval
for (x in 1:n) {
hours <- c(hours, val)
val <- val + interval
}
time <- aggregate(data$request_sum, list(cut(data$response_time_mili, breaks=hours)), sum)
time$minute <- seq.int(nrow(time))
png('throughput.png')
ggplot(data=time, aes(x=minute, y=request_sum, group=1)) +
geom_bar(stat="identity", fill="#56B4E9") +
xlab("Hora do Dia") + ylab("Successful Responses")
dev.off()
##############################################################################
#rate_data <- split(data, data$result)
#success <- rate_data[['success']]
#error <- rate_data[['error']]
#
#success$response_time <- success$response_time_mili - success$request_time_mili
#success['request_sum'] <- sapply(success['request'], sum )
#success['request_time'] <- sapply(success['request'], function(x) format(x, "%H:%M"))
#
#success['simulation_response'] <- success['simulation_time'] + success['response_time']
#success['simulation_response'] <- sapply(success['simulation_response'], function(x) as.numeric(x))
#
#theme_set(theme_gray(base_size = 18))
#png('response_time_boxplot.png')
#boxplot(success$response_time, outline=FALSE)
#dev.off()
##############################################################################
rate_data <- split(data, data$result)
success <- rate_data[['success']]
error <- rate_data[['error']]
success$response_time <- success$response_time_mili - success$request_time_mili
success['simulation_response'] <- success['simulation_time'] + success['response_time']
success['simulation_response'] <- sapply(success['simulation_response'], function(x) as.numeric(x))
interval <- 60000
n <- (max(data$request_time_mili) - min(data$request_time_mili))/interval
hours <- c()
val <- min(data$request_time_mili)
for (x in 1:n) {
hours <- c(hours, val)
val <- val + 60000
}
time <- aggregate(success$response_time, list(cut(success$request_time_mili, breaks=hours)), mean)
time$minute <- seq.int(nrow(time))
png('response_time.png')
ggplot(data=time, aes(x=minute, y=x, group=1)) +
geom_bar(stat="identity", fill="#56B4E9") +
xlab("Hora do Dia") + ylab("Response Time (miliseconds)")
dev.off()
################### COUNT ERRORS
result <- data$result
rate <- as.data.frame(table(result))
Estado <- c("Erro", "Sucesso")
theme_set(theme_gray(base_size = 18))
png('rate.png')
ggplot(rate, aes(result, Freq, fill=Estado)) + geom_bar(stat="identity", width=.6) +
xlab("Estado da resposta da requisição") + ylab("Requisições") +
theme(axis.text.x=element_blank(), axis.ticks.x=element_blank())
dev.off()
################### COUNT ERRORS BY MINUTE
data_error <- data[data$result == 'error',]
time <- aggregate(data_error$request_sum, list(cut(data_error$request_time_mili, breaks=hours)), sum)
time$minute <- seq.int(nrow(time))
png('error_minute.png')
ggplot(data=time, aes(x=minute, y=request_sum, group=1)) +
geom_bar(stat="identity", fill="#56B4E9") +
xlab("Experiment Time (min)") + ylab("Error Count")
dev.off()
print("DONE")