MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / rolling_sample_hyperfine

Function rolling_sample_hyperfine

atomic-cli/src/commands/git/stream.rs:4504–4589  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 13

rolling_sampleFunction · 0.85
checked_git_shaMethod · 0.80
import_graph_streamMethod · 0.80
effective_historyMethod · 0.80
openFunction · 0.50
initFunction · 0.50
writeFunction · 0.50
unwrapMethod · 0.45
current_viewMethod · 0.45
parseMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected