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.

site_load.rs 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //! Benchmarking loading/markdown rendering of generated sites of various sizes
  2. #![feature(test)]
  3. extern crate test;
  4. extern crate gutenberg;
  5. use std::env;
  6. use gutenberg::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. //}