library(ggplot2)

d <- read.table("perf.dat", header=TRUE, fill=TRUE)

listOPs <- c("acceder", "remplir", "supprimer")
listStructs <- c("arraylist", "hashmap", "vector")
for (operation in listOPs) {
        ggplot(d[d$Operation == operation ,], aes(x=n, y=Temps, color=Structure)) +
            geom_point() + geom_smooth() +
            ggtitle(operation) + xlab("Nombre d'éléments") + ylab("Temps d'exécution") +
            theme(plot.title = element_text(hjust = 0.5)) + facet_grid(Structure ~ Operation)
        ggsave(paste(operation, "_tps.png", sep=""))
        ggplot(d[d$Operation == operation ,], aes(x=n, y=Mem, color=Structure)) +
            geom_point() + geom_smooth() +
            ggtitle(operation) + xlab("Nombre d'éléments") + ylab("Consommation mémoire") +
            theme(plot.title = element_text(hjust = 0.5)) + facet_grid(Structure ~ Operation)
        ggsave(paste(operation, "_mem.png", sep=""))
}
