(using the best performing scripts for a selection of languages). Four perforrmance categories were identified by using heirarchical clustering via the following R Script:
library(ggplot2)
# Enter the data in such a way to match the Plot
data <-
rbind(
c("C", 0.97),
c("C++", 0.84),
c("Go", 3.75),
c("Rust", 0.93),
c("Julia", 1.32),
c("Python", 163 ),
c("Lua", 113),
c("Swift", 1.4 ),
c("Intel Fortran", 1.42),
c("Haskell GHC", 1.51),
c("C#", 3.14),
c("Chapel", 3.34),
c("F#", 3.77 ),
c("Pascal", 3.86),
c("Ada", 4.02),
c("Node JS", 4.03),
c("LISP", 4.09),
c("Java", 4.15),
c("OCaml", 7.53),
c("Dart", 8.72),
c("Racket", 10.45),
c("PHP", 24.89),
c("Erlang", 44),
c("Ruby", 262)
)
data <- apply(data, 2, rev)
data <- as.data.frame(data)
data[,2] <- as.numeric(data[,2])
data[,2] <- log(data[,2]+1)
# Make a Data Frame
df <- as.data.frame(data)
names(df) <- c("Language", "Time")
df$Language <- factor(seq_len(nrow(df)), labels = df$Language)
df$Time <- as.numeric(df$Time)
# If you want it ordered in descending uncomment below
# df[rank(df$Time), ]
# Make sure the languages keep the order they were given in
# I want them in a specific order
df$Language <- factor(sort(df$Time), labels = df$Language)
factor(df$Language, ordered = TRUE, levels = rank(df$Time))
# Identify clusters with heirarchical clustering
times <- df$Time; names(times) <- df$Language
hc.av <- hclust(dist(times), method = "average")
plot(hc.av)
df$Category <- factor(cutree(tree = hc.av, k = 4))
levels(df$Category) <- rev(levels(df$Category))
# Build the Plot
p <- ggplot(df, aes(x = Language, y = Time, fill = Category )) +
geom_col(col = 'black') +
labs(y = "Log Time",
title = "Comparison of Programming Language", subtitle = "Log Time to Produce 1600² Mandelbrot") +
guides(fill = guide_legend("Performance\nCategory")) +
theme_classic() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
coord_flip()
ggsave("/tmp/barplot_language_speeds.svg")
p