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.

6 years ago
6 years ago
6 years ago
6 years ago
5 years ago
6 years ago
6 years ago
6 years ago
5 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #![feature(test)]
  2. extern crate test;
  3. use std::env;
  4. use library::Paginator;
  5. use site::Site;
  6. use tempfile::tempdir;
  7. fn setup_site(name: &str) -> Site {
  8. let mut path = env::current_dir().unwrap().to_path_buf();
  9. path.push("benches");
  10. path.push(name);
  11. let mut site = Site::new(&path, "config.toml").unwrap();
  12. site.load().unwrap();
  13. site
  14. }
  15. #[bench]
  16. fn bench_render_aliases(b: &mut test::Bencher) {
  17. let mut site = setup_site("big-blog");
  18. let tmp_dir = tempdir().expect("create temp dir");
  19. let public = &tmp_dir.path().join("public");
  20. site.set_output_path(&public);
  21. b.iter(|| site.render_aliases().unwrap());
  22. }
  23. #[bench]
  24. fn bench_render_sitemap(b: &mut test::Bencher) {
  25. let mut site = setup_site("big-blog");
  26. let tmp_dir = tempdir().expect("create temp dir");
  27. let public = &tmp_dir.path().join("public");
  28. site.set_output_path(&public);
  29. b.iter(|| site.render_sitemap().unwrap());
  30. }
  31. #[bench]
  32. fn bench_render_rss_feed(b: &mut test::Bencher) {
  33. let mut site = setup_site("big-blog");
  34. let tmp_dir = tempdir().expect("create temp dir");
  35. let public = &tmp_dir.path().join("public");
  36. site.set_output_path(&public);
  37. b.iter(|| site.render_rss_feed(site.library.read().unwrap().pages_values(), None).unwrap());
  38. }
  39. #[bench]
  40. fn bench_render_taxonomies(b: &mut test::Bencher) {
  41. let mut site = setup_site("small-blog");
  42. let tmp_dir = tempdir().expect("create temp dir");
  43. let public = &tmp_dir.path().join("public");
  44. site.set_output_path(&public);
  45. b.iter(|| site.render_taxonomies().unwrap());
  46. }
  47. #[bench]
  48. fn bench_render_paginated(b: &mut test::Bencher) {
  49. let mut site = setup_site("small-blog");
  50. let tmp_dir = tempdir().expect("create temp dir");
  51. let public = &tmp_dir.path().join("public");
  52. site.set_output_path(&public);
  53. let library = site.library.read().unwrap();
  54. let section = library.sections_values()[0];
  55. let paginator = Paginator::from_section(&section, &library);
  56. b.iter(|| site.render_paginated(public, &paginator));
  57. }
  58. #[bench]
  59. fn bench_populate_sections_medium_blog(b: &mut test::Bencher) {
  60. let mut site = setup_site("medium-blog");
  61. let tmp_dir = tempdir().expect("create temp dir");
  62. let public = &tmp_dir.path().join("public");
  63. site.set_output_path(&public);
  64. b.iter(|| site.populate_sections());
  65. }
  66. #[bench]
  67. fn bench_populate_sections_medium_kb(b: &mut test::Bencher) {
  68. let mut site = setup_site("medium-kb");
  69. let tmp_dir = tempdir().expect("create temp dir");
  70. let public = &tmp_dir.path().join("public");
  71. site.set_output_path(&public);
  72. b.iter(|| site.populate_sections());
  73. }
  74. #[bench]
  75. fn bench_render_markdown_small_blog(b: &mut test::Bencher) {
  76. let mut site = setup_site("small-blog");
  77. let tmp_dir = tempdir().expect("create temp dir");
  78. let public = &tmp_dir.path().join("public");
  79. site.set_output_path(&public);
  80. b.iter(|| site.render_markdown());
  81. }
  82. #[bench]
  83. fn bench_render_markdown_small_kb(b: &mut test::Bencher) {
  84. let mut site = setup_site("small-kb");
  85. let tmp_dir = tempdir().expect("create temp dir");
  86. let public = &tmp_dir.path().join("public");
  87. site.set_output_path(&public);
  88. b.iter(|| site.render_markdown());
  89. }