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.

158 lines
4.4KB

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