plot-functions.r 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. library(readr)
  2. library(dplyr)
  3. library(ggplot2)
  4. library(xtable)
  5. bench_codes <- c(
  6. "binarytrees",
  7. "fannkuch",
  8. "fasta",
  9. "knucleotide",
  10. "mandelbrot",
  11. "nbody",
  12. "spectralnorm",
  13. "cd",
  14. "deltablue",
  15. "havlak",
  16. "json",
  17. "list",
  18. "permute",
  19. "richards",
  20. "towers"
  21. )
  22. bench_names <- c(
  23. "Binary Trees",
  24. "Fannkuch",
  25. "Fasta",
  26. "K-Nucleotide",
  27. "Mandelbrot",
  28. "N-Body",
  29. "Spectral Norm",
  30. "CD",
  31. "Deltablue",
  32. "Havlak",
  33. "Json",
  34. "List",
  35. "Permute",
  36. "Richards",
  37. "Hanoi Towers"
  38. )
  39. impl_codes <- c("lua", "trm", "aot", "jit", "jof", "fun", "ctx")
  40. impl_used <- c("aot", "ctx", "fun")
  41. impl_names <- c("LuaAOT", "Struct", "Functions")
  42. data <- read_csv("times-slow.csv", col_types = cols(
  43. Benchmark = col_factor(bench_codes),
  44. Implementation = col_factor(impl_codes),
  45. N = col_integer(),
  46. Time = col_double()
  47. ))
  48. plot_data <- filter(data, Implementation %in% impl_used)
  49. aggr_data <- data %>%
  50. group_by(Benchmark,Implementation) %>%
  51. summarize(
  52. meanTime=mean(Time),
  53. d=max(max(Time)-meanTime, meanTime-min(Time)))
  54. mean_times <- plot_data %>%
  55. group_by(Benchmark,Implementation) %>%
  56. summarize(groups=Benchmark,Time=mean(Time)) %>%
  57. ungroup()
  58. mean_times_lua <- mean_times %>%
  59. filter(Implementation=="aot") %>%
  60. select(Benchmark, LuaTime=Time)
  61. normal_times <- plot_data %>%
  62. inner_join(mean_times_lua, by=c("Benchmark")) %>%
  63. mutate(Time=Time/LuaTime) %>%
  64. group_by(Benchmark,Implementation) %>%
  65. summarize(
  66. mean_time = mean(Time),
  67. sd_time = sd(Time),
  68. min_time = min(Time),
  69. max_time = max(Time)) %>%
  70. ungroup()
  71. dodge <- position_dodge(0.9)
  72. ggplot(normal_times,
  73. aes(x=Benchmark,y=mean_time,fill=Implementation)) +
  74. geom_col(position=dodge) +
  75. geom_errorbar(aes(ymin=min_time, ymax=max_time), position=dodge, width=.3) +
  76. xlab("Benchmark")+
  77. ylab("Time") +
  78. scale_fill_discrete(type=c("#00ba38", "#B79F00", "#F564E3"), labels=impl_names) +
  79. scale_x_discrete(labels=bench_names) +
  80. scale_y_continuous(limits=c(0.0, 1.8), breaks=seq(from=0.0,to=1.8,by=0.25) ) +
  81. theme(axis.text.x=element_text(angle=30, hjust=1), legend.position = "top",)