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.5KB

  1. //! Benchmarking loading/markdown rendering of generated sites of various sizes
  2. #![feature(test)]
  3. extern crate test;
  4. extern crate site;
  5. use std::env;
  6. use site::Site;
  7. #[bench]
  8. fn bench_loading_small_blog(b: &mut test::Bencher) {
  9. let mut path = env::current_dir().unwrap().to_path_buf();
  10. path.push("benches");
  11. path.push("small-blog");
  12. let mut site = Site::new(&path, "config.toml").unwrap();
  13. b.iter(|| site.load().unwrap());
  14. }
  15. #[bench]
  16. fn bench_loading_small_blog_with_syntax_highlighting(b: &mut test::Bencher) {
  17. let mut path = env::current_dir().unwrap().to_path_buf();
  18. path.push("benches");
  19. path.push("small-blog");
  20. let mut site = Site::new(&path, "config.toml").unwrap();
  21. site.config.highlight_code = Some(true);
  22. b.iter(|| site.load().unwrap());
  23. }
  24. #[bench]
  25. fn bench_loading_medium_blog(b: &mut test::Bencher) {
  26. let mut path = env::current_dir().unwrap().to_path_buf();
  27. path.push("benches");
  28. path.push("medium-blog");
  29. let mut site = Site::new(&path, "config.toml").unwrap();
  30. b.iter(|| site.load().unwrap());
  31. }
  32. #[bench]
  33. fn bench_loading_medium_blog_with_syntax_highlighting(b: &mut test::Bencher) {
  34. let mut path = env::current_dir().unwrap().to_path_buf();
  35. path.push("benches");
  36. path.push("medium-blog");
  37. let mut site = Site::new(&path, "config.toml").unwrap();
  38. site.config.highlight_code = Some(true);
  39. b.iter(|| site.load().unwrap());
  40. }
  41. #[bench]
  42. fn bench_loading_big_blog(b: &mut test::Bencher) {
  43. let mut path = env::current_dir().unwrap().to_path_buf();
  44. path.push("benches");
  45. path.push("big-blog");
  46. let mut site = Site::new(&path, "config.toml").unwrap();
  47. b.iter(|| site.load().unwrap());
  48. }
  49. #[bench]
  50. fn bench_loading_big_blog_with_syntax_highlighting(b: &mut test::Bencher) {
  51. let mut path = env::current_dir().unwrap().to_path_buf();
  52. path.push("benches");
  53. path.push("big-blog");
  54. let mut site = Site::new(&path, "config.toml").unwrap();
  55. site.config.highlight_code = Some(true);
  56. b.iter(|| site.load().unwrap());
  57. }
  58. //#[bench]
  59. //fn bench_loading_huge_blog(b: &mut test::Bencher) {
  60. // let mut path = env::current_dir().unwrap().to_path_buf();
  61. // path.push("benches");
  62. // path.push("huge-blog");
  63. // let mut site = Site::new(&path, "config.toml").unwrap();
  64. //
  65. // b.iter(|| site.load().unwrap());
  66. //}
  67. //
  68. //#[bench]
  69. //fn bench_loading_huge_blog_with_syntax_highlighting(b: &mut test::Bencher) {
  70. // let mut path = env::current_dir().unwrap().to_path_buf();
  71. // path.push("benches");
  72. // path.push("huge-blog");
  73. // let mut site = Site::new(&path, "config.toml").unwrap();
  74. // site.config.highlight_code = Some(true);
  75. //
  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. //
  119. // b.iter(|| site.load().unwrap());
  120. //}
  121. //
  122. //#[bench]
  123. //fn bench_loading_huge_kb_with_syntax_highlighting(b: &mut test::Bencher) {
  124. // let mut path = env::current_dir().unwrap().to_path_buf();
  125. // path.push("benches");
  126. // path.push("huge-kb");
  127. // let mut site = Site::new(&path, "config.toml").unwrap();
  128. // site.config.highlight_code = Some(true);
  129. //
  130. // b.iter(|| site.load().unwrap());
  131. //}