MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / plot_acc_coverage_comparison

Function plot_acc_coverage_comparison

src/bin/evaluate.rs:203–251  ·  view source on GitHub ↗
(deopt: &Deopt)

Source from the content-addressed store, hash-verified

201}
202
203fn plot_acc_coverage_comparison(deopt: &Deopt) -> Result<()> {
204 let bench_file = get_acc_coverage_bench_file(deopt)?;
205 let rand_bench_file = get_acc_coverage_rand_bench_file(deopt)?;
206 if !bench_file.exists() || !rand_bench_file.exists() {
207 eyre::bail!("No bench file found.")
208 }
209 let raw_str = std::fs::read_to_string(bench_file)?;
210 let bench_coverage: Vec<usize> = serde_json::from_str(&raw_str)?;
211
212 let raw_str = std::fs::read_to_string(rand_bench_file)?;
213 let rand_coverage: Vec<usize> = serde_json::from_str(&raw_str)?;
214
215 let x_limit = usize::max(bench_coverage.len(), rand_coverage.len());
216 let y_limit = usize::max(
217 *bench_coverage.iter().max().unwrap(),
218 *rand_coverage.iter().max().unwrap(),
219 );
220 let x_limit = (x_limit as f32 * 1.1_f32) as usize;
221 let y_limit = (y_limit as f32 * 1.1_f32) as usize;
222
223 let image_save_file = get_acc_coverage_compare_save_image(deopt)?;
224 let root_area = BitMapBackend::new(&image_save_file, (600, 400)).into_drawing_area();
225 root_area.fill(&WHITE).unwrap();
226 let mut ctx = ChartBuilder::on(&root_area)
227 .set_label_area_size(LabelAreaPosition::Left, 40)
228 .set_label_area_size(LabelAreaPosition::Bottom, 40)
229 .caption("Line Plot Demo", ("sans-serif", 40))
230 .build_cartesian_2d(0..x_limit, 0..y_limit)
231 .unwrap();
232
233 ctx.configure_mesh().draw().unwrap();
234 ctx.draw_series(LineSeries::new(
235 bench_coverage
236 .iter()
237 .enumerate()
238 .map(|(id, coverage)| (id, *coverage)),
239 &RED,
240 ))
241 .unwrap();
242 ctx.draw_series(LineSeries::new(
243 rand_coverage
244 .iter()
245 .enumerate()
246 .map(|(id, coverage)| (id, *coverage)),
247 &GREEN,
248 ))
249 .unwrap();
250 Ok(())
251}
252
253fn coverage(project: String, kind: &ACCKind, is_rand_bench: bool) -> Result<()> {
254 let deopt = Deopt::new(project)?;

Callers 1

coverageFunction · 0.85

Tested by

no test coverage detected