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

Function run

atomic-repository/examples/materialize_bench.rs:542–614  ·  view source on GitHub ↗
(config: Config)

Source from the content-addressed store, hash-verified

540}
541
542fn run(config: Config) -> Result<()> {
543 config.validate()?;
544 let parent = config
545 .output
546 .parent()
547 .filter(|p| !p.as_os_str().is_empty())
548 .unwrap_or(Path::new("."));
549 fs::create_dir_all(parent)?;
550 let binary = std::env::current_exe()?;
551 let binary_hash = blake3::hash(&fs::read(&binary)?).to_hex().to_string();
552 let mut fixtures = [
553 Fixture::new(parent, &config, false)?,
554 Fixture::new(parent, &config, true)?,
555 ];
556 for view in ["dev", "bench-near", "bench-far"] {
557 let left = &fixtures[0].golden[view];
558 let right = &fixtures[1].golden[view];
559 ensure!(
560 left.iter()
561 .zip(right)
562 .all(|(a, b)| a.path == b.path && a.content == b.content && a.mode == b.mode),
563 "graph/span fixture mismatch for {view}"
564 );
565 }
566 let mut samples = Vec::new();
567 for iteration in 0..config.warmups + config.iterations {
568 for case in CASES {
569 for offset in 0..2 {
570 let index = (iteration + offset) % 2;
571 let measured = sample(
572 &mut fixtures[index],
573 case,
574 iteration.saturating_sub(config.warmups),
575 )
576 .with_context(|| {
577 format!("{} {case}, iteration {iteration}", fixtures[index].backend)
578 })?;
579 if iteration >= config.warmups {
580 samples.push(measured);
581 }
582 }
583 }
584 }
585 ensure!(
586 blake3::hash(&fs::read(&binary)?).to_hex().as_str() == binary_hash,
587 "benchmark binary changed during run"
588 );
589 let setup: Vec<_> = fixtures.iter().map(|f| serde_json::json!({"backend":f.backend,"setup_ns":f.setup_ns,
590 "database_bytes_after_samples":fs::metadata(f.directory.path().join(".atomic/atomic.redb")).map(|m|m.len()).ok()})).collect();
591 let mut retained = Vec::new();
592 for fixture in fixtures {
593 drop(fixture.repo);
594 if config.keep_fixtures {
595 retained.push(fixture.directory.keep());
596 }
597 }
598 let report = serde_json::json!({"schema":1,"config":config,"binary_blake3":binary_hash,
599 "debug_build":cfg!(debug_assertions),"platform":{"os":std::env::consts::OS,"arch":std::env::consts::ARCH},

Callers 7

mainFunction · 0.70
invoke_checkerFunction · 0.50
wip_lease_repoFunction · 0.50
init_real_git_repoFunction · 0.50
recorded_query_resourcesFunction · 0.50

Calls 13

parentMethod · 0.80
sampleFunction · 0.70
hashFunction · 0.50
readFunction · 0.50
validateMethod · 0.45
is_emptyMethod · 0.45
to_hexMethod · 0.45
with_contextMethod · 0.45
pushMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
openMethod · 0.45