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.

84 lines
2.5KB

  1. //! Benchmarking writing down on the hard drive 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 gutenberg::Site;
  8. use tempdir::TempDir;
  9. #[bench]
  10. fn bench_rendering_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. let tmp_dir = TempDir::new("example").expect("create temp dir");
  16. let public = &tmp_dir.path().join("public");
  17. site.set_output_path(&public);
  18. site.load().unwrap();
  19. b.iter(|| site.build().unwrap());
  20. }
  21. #[bench]
  22. fn bench_rendering_medium_blog(b: &mut test::Bencher) {
  23. let mut path = env::current_dir().unwrap().to_path_buf();
  24. path.push("benches");
  25. path.push("medium-blog");
  26. let mut site = Site::new(&path, "config.toml").unwrap();
  27. let tmp_dir = TempDir::new("example").expect("create temp dir");
  28. let public = &tmp_dir.path().join("public");
  29. site.set_output_path(&public);
  30. site.load().unwrap();
  31. b.iter(|| site.build().unwrap());
  32. }
  33. //#[bench]
  34. //fn bench_rendering_big_blog(b: &mut test::Bencher) {
  35. // let mut path = env::current_dir().unwrap().to_path_buf();
  36. // path.push("benches");
  37. // path.push("big-blog");
  38. // let mut site = Site::new(&path, "config.toml").unwrap();
  39. // let tmp_dir = TempDir::new("example").expect("create temp dir");
  40. // let public = &tmp_dir.path().join("public");
  41. // site.set_output_path(&public);
  42. // site.load().unwrap();
  43. //
  44. // b.iter(|| site.build().unwrap());
  45. //}
  46. #[bench]
  47. fn bench_rendering_small_kb(b: &mut test::Bencher) {
  48. let mut path = env::current_dir().unwrap().to_path_buf();
  49. path.push("benches");
  50. path.push("small-kb");
  51. let mut site = Site::new(&path, "config.toml").unwrap();
  52. let tmp_dir = TempDir::new("example").expect("create temp dir");
  53. let public = &tmp_dir.path().join("public");
  54. site.set_output_path(&public);
  55. site.load().unwrap();
  56. b.iter(|| site.build().unwrap());
  57. }
  58. #[bench]
  59. fn bench_rendering_medium_kb(b: &mut test::Bencher) {
  60. let mut path = env::current_dir().unwrap().to_path_buf();
  61. path.push("benches");
  62. path.push("medium-kb");
  63. let mut site = Site::new(&path, "config.toml").unwrap();
  64. let tmp_dir = TempDir::new("example").expect("create temp dir");
  65. let public = &tmp_dir.path().join("public");
  66. site.set_output_path(&public);
  67. site.load().unwrap();
  68. b.iter(|| site.build().unwrap());
  69. }