-
Notifications
You must be signed in to change notification settings - Fork 0
/
statistic.R
51 lines (40 loc) · 1.38 KB
/
statistic.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
require(ggplot2)
path = '/home/tyamgin/CLionProjects/hlcupdocs-master/logs/2017-08-29_21-27-52.J3vx32/phout_5pVxiS.log'
conn = file(path, open="r")
linn = readLines(conn)
close(conn)
processLine = function (line) {
parts = strsplit(line, '\t', fixed=T)[[1]]
query = strsplit(parts[1], '.', fixed=T)[[1]]
c(query[1], query[2], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7])
}
X = matrix(sapply(linn, processLine), nrow=length(linn), byrow=T)
X[, 1] = as.integer(X[, 1])
X[, 4] = as.integer(X[, 4])
X[, 5] = as.integer(X[, 5])
X[, 6] = as.integer(X[, 6])
X[, 7] = as.integer(X[, 7])
X[, 8] = as.integer(X[, 8])
colnames(X) <- c('timestamp', 'entity_id', 'type', 'sum', 'connect', 'write', 'latency', 'read')
X = data.frame(
timestamp = as.integer(X[, 1]),
entity_id = X[, 2],
type = X[, 3],
sum = as.integer(X[, 4]) / 1e6,
connect = as.integer(X[, 5]) / 1e6,
write = as.integer(X[, 6]) / 1e6,
latency = as.integer(X[, 7]) / 1e6,
read = as.integer(X[, 8]) / 1e6
)
cat('Summary:\n')
cat(paste0('sum ', sum(X$sum), ' sec'))
cat('\n')
sum_aggr = aggregate(X$sum, list(X$timestamp), sum)
sum_aggr$color = 1
latency_aggr = aggregate(X$latency, list(X$timestamp), sum)
latency_aggr$color = 2
data = rbind(sum_aggr, latency_aggr)
print(
ggplot(NULL, aes(x=data[, 1], y=data[, 2], group=data[,3], color=data[,3])) + geom_point() + geom_line()
)
print(X[which(X$sum > 0.5), ])