MCPcopy Create free account
hub / github.com/hashintel/hash / run_scenario

Function run_scenario

tests/graph/benches/graph/scenario/runner.rs:95–141  ·  view source on GitHub ↗
(
    scenario: &Scenario,
    name: &str,
    runtime: &Runtime,
    benchmark_group: &mut BenchmarkGroup<M>,
)

Source from the content-addressed store, hash-verified

93
94#[tracing::instrument(level = "warn", skip_all, fields(otel.name = format!(r#"Scenario "{name}""#)))]
95pub fn run_scenario<M: Measurement>(
96 scenario: &Scenario,
97 name: &str,
98 runtime: &Runtime,
99 benchmark_group: &mut BenchmarkGroup<M>,
100) {
101 let mut runner = Runner::new(RunId::new(scenario.run_id), scenario.num_shards);
102 {
103 for stage in &scenario.setup {
104 let value = runtime
105 .block_on(stage.execute(&mut runner))
106 .expect("Could not execute stage");
107 tracing::info!(scenario = %name, stage = %stage.id(), result = %value, "Step completed");
108 }
109 }
110
111 for bench in &scenario.benches {
112 let _telemetry_guard = init_tracing(name, &bench.name);
113 let _bench_span =
114 tracing::info_span!("Bench", otel.name = format!(r#"Bench "{}""#, bench.name))
115 .entered();
116 let iteration = AtomicUsize::new(0);
117 benchmark_group.bench_function(BenchmarkId::new(name, &bench.name), |bencher| {
118 bencher.to_async(runtime).iter_batched(
119 || (runner.clone(), &iteration),
120 |(mut runner, iteration)| async move {
121 let current_iteration = iteration.fetch_add(1, atomic::Ordering::Relaxed);
122 for stage in &bench.steps {
123 let _stage_span = tracing::info_span!(
124 "Stage",
125 otel.name = format!(r#"Stage "{}""#, stage.id()),
126 )
127 .entered();
128
129 let result = Box::pin(stage.execute(&mut runner))
130 .await
131 .expect("stage failed");
132 if current_iteration == 0 {
133 tracing::info!(result = %result, "Bench stage completed");
134 }
135 }
136 },
137 BatchSize::LargeInput,
138 );
139 });
140 }
141}
142
143#[derive(Debug, Default, Clone)]
144pub struct Resources {

Callers 1

run_scenario_fileFunction · 0.85

Calls 4

init_tracingFunction · 0.50
expectMethod · 0.45
executeMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected