You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
4.5KB

  1. //! Benchmarking generated sites of various sizes
  2. #![feature(test)]
  3. extern crate test;
  4. extern crate gutenberg;
  5. extern crate tempdir;
  6. use std::env;
  7. use tempdir::TempDir;
  8. use gutenberg::Site;
  9. #[bench]
  10. fn bench_loading_small_blog(b: &mut test::Bencher) {
  11. let mut path = env::current_dir().unwrap().to_path_buf();
  12. path.push("benches");
  13. path.push("small-blog");
  14. let mut site = Site::new(&path, "config.toml").unwrap();
  15. b.iter(|| site.load().unwrap());
  16. }
  17. #[bench]
  18. fn bench_loading_small_blog_with_syntax_highlighting(b: &mut test::Bencher) {
  19. let mut path = env::current_dir().unwrap().to_path_buf();
  20. path.push("benches");
  21. path.push("small-blog");
  22. let mut site = Site::new(&path, "config.toml").unwrap();
  23. site.config.highlight_code = Some(true);
  24. b.iter(|| site.load().unwrap());
  25. }
  26. #[bench]
  27. fn bench_loading_medium_blog(b: &mut test::Bencher) {
  28. let mut path = env::current_dir().unwrap().to_path_buf();
  29. path.push("benches");
  30. path.push("medium-blog");
  31. let mut site = Site::new(&path, "config.toml").unwrap();
  32. b.iter(|| site.load().unwrap());
  33. }
  34. //#[bench]
  35. //fn bench_loading_medium_blog_with_syntax_highlighting(b: &mut test::Bencher) {
  36. // let mut path = env::current_dir().unwrap().to_path_buf();
  37. // path.push("benches");
  38. // path.push("medium-blog");
  39. // let mut site = Site::new(&path, "config.toml").unwrap();
  40. // site.config.highlight_code = Some(true);
  41. //
  42. // b.iter(|| site.load().unwrap());
  43. //}
  44. #[bench]
  45. fn bench_loading_big_blog(b: &mut test::Bencher) {
  46. let mut path = env::current_dir().unwrap().to_path_buf();
  47. path.push("benches");
  48. path.push("big-blog");
  49. let mut site = Site::new(&path, "config.toml").unwrap();
  50. b.iter(|| site.load().unwrap());
  51. }
  52. #[bench]
  53. fn bench_loading_big_blog_with_syntax_highlighting(b: &mut test::Bencher) {
  54. let mut path = env::current_dir().unwrap().to_path_buf();
  55. path.push("benches");
  56. path.push("big-blog");
  57. let mut site = Site::new(&path, "config.toml").unwrap();
  58. site.config.highlight_code = Some(true);
  59. b.iter(|| site.load().unwrap());
  60. }
  61. #[bench]
  62. fn bench_loading_huge_blog(b: &mut test::Bencher) {
  63. let mut path = env::current_dir().unwrap().to_path_buf();
  64. path.push("benches");
  65. path.push("huge-blog");
  66. let mut site = Site::new(&path, "config.toml").unwrap();
  67. b.iter(|| site.load().unwrap());
  68. }
  69. #[bench]
  70. fn bench_loading_huge_blog_with_syntax_highlighting(b: &mut test::Bencher) {
  71. let mut path = env::current_dir().unwrap().to_path_buf();
  72. path.push("benches");
  73. path.push("huge-blog");
  74. let mut site = Site::new(&path, "config.toml").unwrap();
  75. site.config.highlight_code = Some(true);
  76. b.iter(|| site.load().unwrap());
  77. }
  78. #[bench]
  79. fn bench_loading_small_kb(b: &mut test::Bencher) {
  80. let mut path = env::current_dir().unwrap().to_path_buf();
  81. path.push("benches");
  82. path.push("small-kb");
  83. let mut site = Site::new(&path, "config.toml").unwrap();
  84. b.iter(|| site.load().unwrap());
  85. }
  86. #[bench]
  87. fn bench_loading_small_kb_with_syntax_highlighting(b: &mut test::Bencher) {
  88. let mut path = env::current_dir().unwrap().to_path_buf();
  89. path.push("benches");
  90. path.push("small-kb");
  91. let mut site = Site::new(&path, "config.toml").unwrap();
  92. site.config.highlight_code = Some(true);
  93. b.iter(|| site.load().unwrap());
  94. }
  95. #[bench]
  96. fn bench_loading_medium_kb(b: &mut test::Bencher) {
  97. let mut path = env::current_dir().unwrap().to_path_buf();
  98. path.push("benches");
  99. path.push("medium-kb");
  100. let mut site = Site::new(&path, "config.toml").unwrap();
  101. b.iter(|| site.load().unwrap());
  102. }
  103. #[bench]
  104. fn bench_loading_medium_kb_with_syntax_highlighting(b: &mut test::Bencher) {
  105. let mut path = env::current_dir().unwrap().to_path_buf();
  106. path.push("benches");
  107. path.push("medium-kb");
  108. let mut site = Site::new(&path, "config.toml").unwrap();
  109. site.config.highlight_code = Some(true);
  110. b.iter(|| site.load().unwrap());
  111. }
  112. #[bench]
  113. fn bench_loading_huge_kb(b: &mut test::Bencher) {
  114. let mut path = env::current_dir().unwrap().to_path_buf();
  115. path.push("benches");
  116. path.push("huge-kb");
  117. let mut site = Site::new(&path, "config.toml").unwrap();
  118. b.iter(|| site.load().unwrap());
  119. }
  120. #[bench]
  121. fn bench_loading_huge_kb_with_syntax_highlighting(b: &mut test::Bencher) {
  122. let mut path = env::current_dir().unwrap().to_path_buf();
  123. path.push("benches");
  124. path.push("huge-kb");
  125. let mut site = Site::new(&path, "config.toml").unwrap();
  126. site.config.highlight_code = Some(true);
  127. b.iter(|| site.load().unwrap());
  128. }