()
| 4498 | #[test] |
| 4499 | #[ignore = "real rolling import sample; set ATOMIC_ROLLING_GIT and ATOMIC_ROLLING_ARTIFACT"] |
| 4500 | fn rolling_sample_hyperfine() { |
| 4501 | let git = GitRepository::open(std::env::var_os("ATOMIC_ROLLING_GIT").unwrap()).unwrap(); |
| 4502 | let artifact = PathBuf::from(std::env::var_os("ATOMIC_ROLLING_ARTIFACT").unwrap()); |
| 4503 | fs::create_dir_all(&artifact).unwrap(); |
| 4504 | assert!( |
| 4505 | !artifact.join("repo").exists(), |
| 4506 | "sample target must be fresh" |
| 4507 | ); |
| 4508 | let mut repo = Repository::init(artifact.join("repo")).unwrap(); |
| 4509 | let importer = ParallelImporter::new( |
| 4510 | &git, |
| 4511 | ParallelImportOptions { |
| 4512 | graph_only: true, |
| 4513 | target_view: repo.current_view().into(), |
| 4514 | ..Default::default() |
| 4515 | }, |
| 4516 | ); |
| 4517 | let tip = Oid::from_str("c5161524980522320c7d3425e714cc0965a869a5").unwrap(); |
| 4518 | let ordered = importer.collect_commit_oids_from_tip(&git, tip).unwrap(); |
| 4519 | assert_eq!(ordered.len(), 1097); |
| 4520 | let start = Instant::now(); |
| 4521 | let window_mib: usize = std::env::var("ATOMIC_ROLLING_WINDOW_MIB") |
| 4522 | .unwrap_or_else(|_| "512".into()) |
| 4523 | .parse() |
| 4524 | .unwrap(); |
| 4525 | let window_bytes = window_mib.checked_mul(1024 * 1024).unwrap(); |
| 4526 | let (outcome, advances, peak, peak_bytes, stalls, preflight_seconds) = |
| 4527 | rolling_sample(&importer, &mut repo, tip, 500, 100, window_bytes).unwrap(); |
| 4528 | let elapsed_seconds = start.elapsed().as_secs_f64(); |
| 4529 | assert_eq!(outcome.commits, ordered.len()); |
| 4530 | assert!(advances >= 5); |
| 4531 | assert!(peak <= 500); |
| 4532 | assert_eq!(fs::read_dir(repo.root()).unwrap().count(), 1); |
| 4533 | drop(repo); |
| 4534 | let repo = Repository::open(artifact.join("repo")).unwrap(); |
| 4535 | assert_eq!(repo.effective_history(None).unwrap().len(), ordered.len()); |
| 4536 | for oid in &ordered { |
| 4537 | let hash = repo.checked_git_sha(&oid.to_string()).unwrap().unwrap(); |
| 4538 | assert!(repo.load_change(&hash).unwrap().file_ops().is_empty()); |
| 4539 | } |
| 4540 | assert!(!artifact.join("baseline").exists()); |
| 4541 | let mut baseline = Repository::init(artifact.join("baseline")).unwrap(); |
| 4542 | let baseline_start = Instant::now(); |
| 4543 | let direct = importer |
| 4544 | .import_graph_stream( |
| 4545 | &mut baseline, |
| 4546 | tip, |
| 4547 | GitStreamLimits::new(100, 32 * 1024 * 1024).unwrap(), |
| 4548 | ) |
| 4549 | .unwrap(); |
| 4550 | let baseline_seconds = baseline_start.elapsed().as_secs_f64(); |
| 4551 | assert_eq!(outcome.state, direct.state); |
| 4552 | let rolling_history: Vec<_> = repo |
| 4553 | .effective_history(None) |
| 4554 | .unwrap() |
| 4555 | .iter() |
| 4556 | .map(|entry| entry.hash) |
| 4557 | .collect(); |
nothing calls this directly
no test coverage detected