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.

sorting.rs 701B

7 years ago
123456789101112131415161718192021222324252627
  1. //! Benchmarking separate functions of Gutenberg
  2. #![feature(test)]
  3. extern crate test;
  4. extern crate gutenberg;
  5. extern crate tempdir;
  6. use std::env;
  7. use tempdir::TempDir;
  8. use gutenberg::{Site, sort_pages, SortBy};
  9. fn setup_site(name: &str) -> Site {
  10. let mut path = env::current_dir().unwrap().to_path_buf();
  11. path.push("benches");
  12. path.push(name);
  13. let mut site = Site::new(&path, "config.toml").unwrap();
  14. site.load().unwrap();
  15. site
  16. }
  17. #[bench]
  18. fn bench_sort_pages_medium_blog(b: &mut test::Bencher) {
  19. let mut site = setup_site("huge-blog");
  20. let section = site.sections.values().next().unwrap().clone();
  21. b.iter(|| sort_pages(section.pages.clone(), SortBy::None));
  22. }