plot.r 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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("lua", "trm", "aot", "jit", "fun", "ctx")
  41. #impl_names <- c("Lua", "Trampoline", "LuaAOT","LuaJIT", "Function", "Struct")
  42. impl_used <- c("lua", "aot", "jit")
  43. impl_names <- c("Lua", "LuaAOT","LuaJIT")
  44. data <- read_csv("times-slow.csv", col_types = cols(
  45. Benchmark = col_factor(bench_codes),
  46. Implementation = col_factor(impl_codes),
  47. N = col_integer(),
  48. Time = col_double()
  49. ))
  50. plot_data <- filter(data, Implementation %in% impl_used)
  51. aggr_data <- data %>%
  52. group_by(Benchmark,Implementation) %>%
  53. summarize(
  54. meanTime=mean(Time),
  55. d=max(max(Time)-meanTime, meanTime-min(Time)))
  56. mean_times <- plot_data %>%
  57. group_by(Benchmark,Implementation) %>%
  58. summarize(Time=mean(Time)) %>%
  59. ungroup()
  60. mean_times_lua <- mean_times %>%
  61. filter(Implementation=="lua") %>%
  62. select(Benchmark, LuaTime=Time)
  63. normal_times <- plot_data %>%
  64. inner_join(mean_times_lua, by=c("Benchmark")) %>%
  65. mutate(Time=Time/LuaTime) %>%
  66. group_by(Benchmark,Implementation) %>%
  67. summarize(
  68. mean_time = mean(Time),
  69. sd_time = sd(Time),
  70. min_time = min(Time),
  71. max_time = max(Time)) %>%
  72. ungroup()
  73. dodge <- position_dodge(0.9)
  74. ggplot(normal_times,
  75. aes(x=Benchmark,y=mean_time,fill=Implementation)) +
  76. geom_col(position=dodge) +
  77. geom_errorbar(aes(ymin=min_time, ymax=max_time), position=dodge, width=.3)+
  78. xlab("Benchmark")+
  79. ylab("Time")+
  80. scale_fill_discrete(labels=impl_names) +
  81. scale_x_discrete(labels=bench_names) +
  82. scale_y_continuous(limits=c(0.0, 1.2), breaks=seq(from=0.0,to=1.2,by=0.25) ) +
  83. theme(axis.text.x=element_text(angle=30, hjust=1), legend.position = "top",)
  84. ##########
  85. trm_times <- data %>%
  86. filter(Implementation %in% c("trm", "cor")) %>%
  87. group_by(Benchmark,Implementation) %>%
  88. summarize(Time=mean(Time)) %>%
  89. ungroup()
  90. trm_ratio <- inner_join(
  91. filter(trm_times, Implementation=="trm"),
  92. filter(trm_times, Implementation=="cor"),
  93. by=c("Benchmark")) %>%
  94. mutate(Ratio=100.0*Time.x/Time.y) %>%
  95. select(Benchmark, Ratio)