this is for holding javascript data
Brandon Holt plot abort rates by txn type
over 9 years ago
Commit id: b160a480d2990a29281ea01b4e770ddff9c483cd
deletions | additions
diff --git a/data/common.R b/data/common.R
index baeef63..46aecd7 100644
--- a/data/common.R
+++ b/data/common.R
...
suppressPackageStartupMessages(require(RMySQL))
suppressPackageStartupMessages(require(sqldf))
suppressPackageStartupMessages(require(ggplot2))
suppressPackageStartupMessages(require(reshape))
options(RMySQL.dbname="claret") # (rest comes from $HOME/.my.cnf)
db <- function(query, factors=c(), numeric=c()) {
...
as.continuous <- function(var) as.numeric(as.character(var))
save <- function(g,
file=sprintf("%s/%s.pdf",FILE_DIR,FILE_BASE), name=FILE_BASE, file=sprintf("%s/%s.pdf",FILE_DIR,name), w=3.3, h=3.1) {
ggsave(plot=g, filename=file, width=w, height=h)
print(sprintf("saved: %s", file))
}
...
lapply(paste(vname, prettify(as.character(value))), paste, collapse="\n")
}
geom_mean <- function(geom) stat_summary(fun.y='mean', geom=geom, labeller=label_pretty)
geom_meanbar <- function(labeller=label_pretty) {
return(list(
stat_summary(fun.y=mean,
geom='bar'), geom='bar', position='dodge'),
stat_summary(fun.data=mean_cl_normal, geom='errorbar',
width=0.2) width=0.2, position='dodge')
))
}
# The palette with grey:
cbPalette <- c("#0072B2", "#E69F00", "#009E73", "#D55E00", "#CC79A7", "#56B4E9", "#F0E442", "#999999")
theme_mine <-
theme_bw() list(
# To use for fills, add
scale_fill_manual(values=cbPalette),
# To use for line and point colors, add
scale_colour_manual(values=cbPalette),
# basic black and white theme
theme(
panel.background = element_rect(fill="white"),
panel.border = element_rect(fill=NA, color="grey50"),
panel.grid.major = element_line(color="grey80", size=0.2),
panel.grid.minor = element_line(color="grey90", size=0.2),
strip.background = element_rect(fill="grey90", color="grey50"),
strip.background = element_rect(fill="grey80", color="grey50"),
axis.ticks = element_line(colour="black"),
panel.grid = element_line(colour="black"),
axis.text.y = element_text(colour="black"),
axis.text.x = element_text(colour="black"),
text = element_text(size=11, family="Helvetica")
)
)
diff --git a/data/plot.R b/data/plot.R
old mode 100644
new mode 100755
index 05fe1b1..f226519
--- a/data/plot.R
+++ b/data/plot.R
...
#!/usr/bin/env Rscript
source('common.R')
d <- db('select * from
tapir',
factors=c('nshards'), tapir where
generator_time is not null and total_time is not null',
factors=c('nshards', 'nclients'),
numeric=c('total_time', 'txn_count'))
d$txn_abort_rate <- d$txn_failed / d$txn_count + d$txn_failed
d$throughput <- d$txn_count *
d$nclients as.numeric(d$nclients) / d$total_time
common_layers <- list(theme_mine
,
facet_grid(nshards~., facet_grid(.~nshards, labeller=label_pretty)
)
save(ggplot(d, save(
ggplot(d, aes(
x = nclients,
y = throughput,
fill = nshards,
...
))+
geom_meanbar()+
common_layers
, w=4, h=3)
d.m <- melt(d,
measure=c(
'retwis_newuser_success',
'retwis_post_success',
'retwis_timeline_success',
'retwis_follow_success'
)
)
d.m$txn_type <- unlist(lapply(
d.m$variable,
function(s) gsub('retwis_(\\w+)_success','\\1', s))
)
save(
ggplot(d.m, aes(
x = nclients,
y = value,
fill = txn_type,
))+
# geom_meanbar()+
stat_summary(fun.y='mean', geom='bar', position='dodge')+
common_layers+
facet_grid(nshards~initusers, labeller=label_pretty)
, name='abort_rates', w=8, h=6)