MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / run

Method run

src/executor/analysis/executor.rs:84–148  ·  view source on GitHub ↗
(
        &mut self,
        execution_context: &ExecutionContext,
        _mongo_tracer: &Option<MongoTracer>,
    )

Source from the content-addressed store, hash-verified

82 }
83
84 async fn run(
85 &mut self,
86 execution_context: &ExecutionContext,
87 _mongo_tracer: &Option<MongoTracer>,
88 ) -> Result<()> {
89 let mut instruments = enabled_instruments(&execution_context.config.instruments);
90 let mut instruments_env = HashMap::new();
91 for instrument in instruments.iter_mut() {
92 instrument
93 .start(&execution_context.profile_folder, &mut instruments_env)
94 .await?;
95 }
96
97 let (_env_file, _script_file, cmd_builder) =
98 self.bench_cmd(execution_context, instruments_env)?;
99 let cmd = cmd_builder.build().into();
100 debug!("cmd: {cmd:?}");
101
102 let mut runner_fifo = RunnerFifo::new()?;
103 let timestamps = &self.timestamps;
104 let fifo_instruments = &mut instruments;
105 let result = run_command_with_log_pipe_and_callback(cmd, async move |mut child| {
106 let on_cmd = async |cmd: &FifoCommand| {
107 match cmd {
108 // Run each benchmark once.
109 FifoCommand::GetIntegrationMode => {
110 return Ok(Some(FifoCommand::IntegrationModeResponse(
111 IntegrationMode::Analysis,
112 )));
113 }
114 FifoCommand::StartProfiler => {
115 for instrument in fifo_instruments.iter_mut() {
116 instrument.on_start_profiler().await?;
117 }
118 }
119 FifoCommand::StopProfiler => {
120 for instrument in fifo_instruments.iter_mut() {
121 instrument.on_stop_profiler().await?;
122 }
123 }
124 _ => {}
125 }
126 Ok(None)
127 };
128 let (marker_result, _fifo_data, exit_status) =
129 runner_fifo.handle_fifo_messages(&mut child, on_cmd).await?;
130 let _ = timestamps.set(marker_result);
131 Ok(exit_status)
132 })
133 .await;
134
135 // Stopped even when the process failed, to release what they hold.
136 for instrument in instruments.iter_mut() {
137 instrument.stop().await?;
138 }
139
140 let status = result.map_err(|e| anyhow!("failed to execute the benchmark process. {e}"))?;
141 debug!("cmd exit status: {status:?}");

Callers

nothing calls this directly

Calls 10

enabled_instrumentsFunction · 0.85
bench_cmdMethod · 0.80
handle_fifo_messagesMethod · 0.80
startMethod · 0.45
buildMethod · 0.45
on_start_profilerMethod · 0.45
on_stop_profilerMethod · 0.45
setMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected