plot.r 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. )
  14. bench_names <- c(
  15. "Binary Trees",
  16. "Fannkuch",
  17. "Fasta",
  18. "K-Nucleotide",
  19. "Mandelbrot",
  20. "N-Body",
  21. "Spectral Norm"
  22. )
  23. impl_codes <- c("lsw","lua","trm", "cor", "aot","jof", "jit")
  24. impl_used <- c("lua", "trm", "cor", "jit")
  25. impl_names <- c("Lua", "Trampoline", "LuaAOT","LuaJIT")
  26. data <- read_csv("times-slow.csv", col_types = cols(
  27. Benchmark = col_factor(bench_codes),
  28. Implementation = col_factor(impl_codes),
  29. N = col_integer(),
  30. Time = col_double()
  31. ))
  32. plot_data <- filter(data, Implementation %in% impl_used)
  33. aggr_data <- data %>%
  34. group_by(Benchmark,Implementation) %>%
  35. summarize(
  36. meanTime=mean(Time),
  37. d=max(max(Time)-meanTime, meanTime-min(Time)))
  38. mean_times <- plot_data %>%
  39. group_by(Benchmark,Implementation) %>%
  40. summarize(Time=mean(Time)) %>%
  41. ungroup()
  42. mean_times_lua <- mean_times %>%
  43. filter(Implementation=="lua") %>%
  44. select(Benchmark, LuaTime=Time)
  45. normal_times <- plot_data %>%
  46. inner_join(mean_times_lua, by=c("Benchmark")) %>%
  47. mutate(Time=Time/LuaTime) %>%
  48. group_by(Benchmark,Implementation) %>%
  49. summarize(
  50. mean_time = mean(Time),
  51. sd_time = sd(Time),
  52. min_time = min(Time),
  53. max_time = max(Time)) %>%
  54. ungroup()
  55. dodge <- position_dodge(0.9)
  56. ggplot(normal_times,
  57. aes(x=Benchmark,y=mean_time,fill=Implementation)) +
  58. geom_col(position=dodge) +
  59. geom_errorbar(aes(ymin=min_time, ymax=max_time), position=dodge, width=.3)+
  60. xlab("Benchmark")+
  61. ylab("Time")+
  62. scale_fill_discrete(labels=impl_names) +
  63. scale_x_discrete(labels=bench_names) +
  64. scale_y_continuous(limits=c(0.0, 1.2), breaks=seq(from=0.0,to=1.2,by=0.25) ) +
  65. theme(axis.text.x=element_text(angle=30, hjust=1), legend.position = "top",)
  66. ##########
  67. trm_times <- data %>%
  68. filter(Implementation %in% c("trm", "cor")) %>%
  69. group_by(Benchmark,Implementation) %>%
  70. summarize(Time=mean(Time)) %>%
  71. ungroup()
  72. trm_ratio <- inner_join(
  73. filter(trm_times, Implementation=="trm"),
  74. filter(trm_times, Implementation=="cor"),
  75. by=c("Benchmark")) %>%
  76. mutate(Ratio=100.0*Time.x/Time.y) %>%
  77. select(Benchmark, Ratio)