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

Function direct_stream_hyperfine

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

Source from the content-addressed store, hash-verified

4985 #[test]
4986 #[ignore = "direct Git-to-graph Hyperfine canary; set ATOMIC_DIRECT_STREAM_GIT and ATOMIC_DIRECT_STREAM_ARTIFACT"]
4987 fn direct_stream_hyperfine() {
4988 let git =
4989 GitRepository::open(std::env::var_os("ATOMIC_DIRECT_STREAM_GIT").unwrap()).unwrap();
4990 let artifact = PathBuf::from(std::env::var_os("ATOMIC_DIRECT_STREAM_ARTIFACT").unwrap());
4991 fs::create_dir_all(&artifact).unwrap();
4992 assert!(!artifact.join("repo").exists());
4993 let mut repo = Repository::init(artifact.join("repo")).unwrap();
4994 let importer = ParallelImporter::new(
4995 &git,
4996 ParallelImportOptions {
4997 graph_only: true,
4998 target_view: repo.current_view().into(),
4999 ..Default::default()
5000 },
5001 );
5002 let all = importer
5003 .collect_commit_oids_from_tip(
5004 &git,
5005 Oid::from_str("c5161524980522320c7d3425e714cc0965a869a5").unwrap(),
5006 )
5007 .unwrap();
5008 let count: usize = std::env::var("ATOMIC_DIRECT_STREAM_COMMITS")
5009 .unwrap_or_else(|_| "100".into())
5010 .parse()
5011 .unwrap();
5012 assert!(count > 0 && count <= all.len());
5013 let started = Instant::now();
5014 let result = importer.import_graph_stream(
5015 &mut repo,
5016 all[count - 1],
5017 GitStreamLimits::new(100, 32 * 1024 * 1024).unwrap(),
5018 );
5019 let elapsed = started.elapsed().as_secs_f64();
5020 let mut report = serde_json::json!({"requested":count,"elapsed_seconds":elapsed,"direct":true,"ordinary_recorder_trap_enabled":true,"source_preparation_pass":false,"graph_only":true,"historical_verification":false,"post_checks":false,"materialized":false,"build_label":std::env::var("ATOMIC_DIRECT_STREAM_BUILD_LABEL").unwrap_or_else(|_|"unoptimized test".into()),"result":result.as_ref().ok().map(|outcome| serde_json::json!({"commits":outcome.commits,"batches":outcome.batches,"state":outcome.state.to_base32(),"private_publish_seconds":outcome.private_publish_seconds,"final_proof_promotion_seconds":outcome.final_proof_promotion_seconds})),"error":result.as_ref().err().map(ToString::to_string)});
5021 fs::write(
5022 artifact.join("direct-result.json"),
5023 serde_json::to_vec_pretty(&report).unwrap(),
5024 )
5025 .unwrap();
5026 println!("DIRECT STREAM {report}");
5027 result.unwrap();
5028 assert_eq!(fs::read_dir(repo.root()).unwrap().count(), 1);
5029 drop(repo);
5030 let repo = Repository::open(artifact.join("repo")).unwrap();
5031 assert_eq!(repo.effective_history(None).unwrap().len(), count);
5032 for oid in &all[..count] {
5033 let hash = repo.checked_git_sha(&oid.to_string()).unwrap().unwrap();
5034 assert!(repo.load_change(&hash).unwrap().file_ops().is_empty());
5035 }
5036 let wc = repo.require_working_copy_id().unwrap();
5037 repo.materialize(wc).unwrap();
5038 assert!(repo
5039 .status(wc, atomic_repository::StatusOptions::default())
5040 .unwrap()
5041 .is_clean());
5042 report["post_checks"] = serde_json::json!(true);
5043 report["materialized"] = serde_json::json!(true);
5044 fs::write(

Callers

nothing calls this directly

Calls 11

import_graph_streamMethod · 0.80
checked_git_shaMethod · 0.80
openFunction · 0.50
initFunction · 0.50
writeFunction · 0.50
unwrapMethod · 0.45
current_viewMethod · 0.45
parseMethod · 0.45
materializeMethod · 0.45

Tested by

no test coverage detected