Skip to content

Instantly share code, notes, and snippets.

@randyzwitch
Created September 2, 2013 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randyzwitch/6414244 to your computer and use it in GitHub Desktop.
Save randyzwitch/6414244 to your computer and use it in GitHub Desktop.
Graph code for JIT comparison blog post
library(ggplot2)
library(reshape2)
jit <- read.csv("~/Desktop/jit.csv")
#Melt data into proper format
jitm <- melt(jit, id.vars='numsearch')
jitm$value = log(jitm$value)
#Create Overall ggplot for ln performance
ggplot(jitm) +
theme_bw(base_family="Garamond") +
theme(text = element_text(size=20)) +
ggtitle("Language Speed Comparison\n") +
xlab("\nFactorial Divisor Search") +
ylab("ln(seconds)\n") +
geom_line(aes(x=numsearch, y=value, colour=variable), size=1.2) +
guides(colour = guide_legend(title=NULL, override.aes = list(size=3))) +
scale_x_continuous(breaks=5:20) +
scale_y_continuous(breaks=NULL) +
scale_color_manual(values=c("slateblue2", "goldenrod1", "springgreen3", "lightsalmon2", "gray30", "darkgreen", "gold3", "pink"))
#Create ggplot for ln performance
#Python
python <- subset(jitm, variable == "python" | variable == "pypy" | variable == "python.numba.autojit")
ggplot(python) +
theme_bw(base_family="Garamond") +
theme(text = element_text(size=20)) +
ggtitle("Language Speed Comparison - Python\n") +
xlab("\nFactorial Divisor Search") +
ylab("ln(seconds)\n") +
geom_line(aes(x=numsearch, y=value, colour=variable), size=1.2) +
guides(colour = guide_legend(title=NULL, override.aes = list(size=3))) +
scale_x_continuous(breaks=5:20) +
scale_y_continuous(breaks=NULL) +
scale_color_manual(values=c("slateblue2", "goldenrod1", "springgreen3", "lightsalmon2", "gray30", "darkgreen", "gold3", "pink"))
#Create ggplot for ln performance
#R
r <- subset(jitm, variable == "r" | variable == "r.compiled" | variable == "pqr" | variable == "pqr.compiled")
ggplot(r) +
theme_bw(base_family="Garamond") +
theme(text = element_text(size=20)) +
ggtitle("Language Speed Comparison - R\n") +
xlab("\nFactorial Divisor Search") +
ylab("ln(seconds)\n") +
geom_line(aes(x=numsearch, y=value, colour=variable), size=1.2) +
guides(colour = guide_legend(title=NULL, override.aes = list(size=3))) +
scale_x_continuous(breaks=5:20) +
scale_y_continuous(breaks=NULL) +
scale_color_manual(values=c("slateblue2", "goldenrod1", "springgreen3", "lightsalmon2", "gray30", "darkgreen", "gold3", "pink"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment