This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
tti-analysis.Rmd
94 lines (80 loc) · 2.66 KB
/
tti-analysis.Rmd
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
---
title: "TTI Analysis"
author: "[email protected]"
date: "December 12, 2016"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(ggplot2)
library(plotly)
library(reshape2)
library(GGally)
```
# Comparison of Time To Interactive Definitions.
```{r}
df = read.csv("data.csv")
df[12:13] <- list(NULL)
df$ttifmp = as.double(df$firstInteractive.FMP) / 1000.0
dfm <- reshape2:::melt.data.frame(df, id=c("url", "trace", "ttifmp"),
variable.name = "measurement",
value.name = "ms")
dfm$ms <- suppressWarnings(as.double(dfm$ms)) # Ignore coercion warnings.
dfm$seconds <- dfm$ms / 1000.0
means = aggregate(ms ~ measurement, data = dfm, FUN = mean)
ordered = means[order(means$ms),][['measurement']]
dfm$measurement = factor(dfm$measurement, levels = ordered)
dfm <- na.omit(dfm)
```
```{r graph, fig.width=10, fig.height=12}
# Breaks used for log graph.
b = c(5,7.5,10,15,20,30,40,50,60,80,100,120)
jitter_plot <- function(df) {
p <- ggplot(aes(x=measurement, y=seconds, color=ttifmp), data=df) +
geom_jitter(alpha = 0.3, aes(text=url)) +
scale_y_continuous(
trans = "log10",
breaks = b,
labels = b) +
theme(
axis.text.x = element_text(angle = 90, hjust = 1, size=15),
axis.text.y = element_text(size=15),
panel.grid.minor.y = element_blank()) +
scale_color_distiller(palette = "Spectral") +
theme(axis.title.x = element_blank())
return(p)
}
p <- jitter_plot(dfm)
print(p)
```
## Interactive version of above graph.
Low number of samples, to make the graph lighter.
```{r graph_interactive, fig.width=10, fig.height=12}
sample_ratio <- 0.1
dfm_samples <- dfm[sample(nrow(dfm), round(nrow(dfm) * sample_ratio)),]
p <- jitter_plot(dfm_samples)
ggplotly(tooltip=c("text"))
```
## Open this in a new tab.
```{r pairs, fig.width=30, fig.height=30}
df_casted <- dcast(dfm, url ~ measurement, value.var="seconds")
df_casted$url = NULL # Don't care about URL
df_casted <- na.omit(df_casted)
generate_scatter <- function(data, mapping, ...){
ggplot(data = data, mapping = mapping) +
geom_point(alpha = 0.1) +
scale_x_continuous(trans = "log10", breaks=b, labels=b) +
scale_y_continuous(trans = "log10", breaks=b, labels=b)
}
generate_density <- function(data, mapping, ...) {
r = ggplot(data = data, mapping = mapping) +
geom_density(..., fill="red", color=NA) +
scale_x_continuous(trans = "log10", breaks=b, labels=b)
r
}
p = ggpairs(df_casted,
lower=list(continuous = generate_scatter),
upper = list(continuous = wrap(ggally_cor, size = 10)),
diag=list(continuous = generate_density))
print(p)
```