Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/benchmarks-mv/blob/main/src/bin/bench_branching_neutral.rs # benchmarks-mv Measurement harnesses and evidence bundles for AIEN on the NVIDIA DGX Spark GB10. Speed is reported against the machine's physical limit and my own previous run. Attachment of AienOS. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `benchmarks-mv / src / bin / bench_branching_neutral.rs` 721 lines ยท 25961 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 //! Neutral out-of-process benchmark runner for agentic branching suites on NVIDIA DGX Spark GB10. 17 //! Supports simultaneous branch dispatch against AIEN and vLLM. 18 //! Sends complete 32K shared prefix + branch suffix tokens, performs continuous 50ms PSS/RSS 19 //! sampling during execution, validates model revision, and records exact token-level ITL distributions. 20 21 use clap::Parser; 22 use futures::StreamExt; 23 use reqwest::Client; 24 use serde::{Deserialize, Serialize}; 25 use sha2::{Digest, Sha256}; 26 use std::fs::{self, File}; 27 use std::io::Write; 28 use std::path::PathBuf; 29 use std::sync::atomic::{AtomicBool, Ordering}; 30 use std::sync::Arc; 31 use std::time::{Duration, Instant}; 32 use tokio::sync::Barrier; 33 34 #[derive(Parser, Debug)] 35 #[command(name = "bench_branching_neutral")] 36 #[command(about = "Neutral Out-of-Process Benchmark Runner for Real-Model Agentic Branching")] 37 struct Args { 38 /// Path to the frozen benchmark manifest JSON 39 #[arg(short, long, default_value = "manifests/qwen25_7b_branching_32k.json")] 40 manifest: PathBuf, 41 42 /// Comma-separated list of target engines: aien, vllm 43 #[arg(short, long, default_value = "aien,vllm")] 44 engines: String, 45 46 /// Comma-separated list of branch counts to sweep: 1,10,25,50,100,250,500 47 #[arg(short, long, default_value = "1,10,25,50,100,250,500")] 48 branches: String, 49 50 /// Repetitions per branch count 51 #[arg(short, long, default_value_t = 3)] 52 repetitions: usize, 53 54 /// Maximum tokens to generate per branch 55 #[arg(long, default_value_t = 256)] 56 max_tokens: usize, 57 58 /// Output directory for trial JSONL and summary results 59 #[arg(short, long, default_value = "data/branching_results")] 60 output_dir: PathBuf, 61 62 /// AIEN base URL 63 #[arg(long, default_value = "http://127.0.0.1:18092/v1")] 64 aien_url: String, 65 66 /// vLLM base URL 67 #[arg(long, default_value = "http://127.0.0.1:18094/v1")] 68 vllm_url: String, 69 70 /// Optional PID of the active engine to monitor smaps_rollup 71 #[arg(long)] 72 engine_pid: Option, 73 74 /// Require exact model ID check against /v1/models 75 #[arg(long, default_value_t = true)] 76 verify_model_id: bool, 77 } 78 79 #[derive(Debug, Clone, Deserialize)] 80 struct Manifest { 81 model_id: String, 82 model_revision: String, 83 prefix_token_count: usize, 84 #[serde(rename = "prefix_token_hash")] 85 _prefix_token_hash: String, 86 prefix_token_ids: Vec, 87 #[serde(rename = "prefix_text")] 88 _prefix_text: Option, 89 branches: Vec, 90 } 91 92 #[derive(Debug, Clone, Deserialize)] 93 struct BranchSpec { 94 branch_id: usize, 95 category: String, 96 #[serde(rename = "text")] 97 _text: String, 98 token_ids: Vec, 99 #[serde(rename = "token_count")] 100 _token_count: usize, 101 #[serde(default)] 102 expected_first_token: Option, 103 #[serde(default)] 104 expected_first_16_tokens: Option>, 105 #[serde(default)] 106 expected_full_tokens: Option>, 107 #[serde(default)] 108 expected_output_tokens: Option>, 109 #[serde(default)] 110 expected_output_hash: Option, 111 #[serde(default)] 112 expected_output_text: Option, 113 } 114 115 #[derive(Debug, Clone, Serialize)] 116 struct BranchTrialResult { 117 branch_id: usize, 118 category: String, 119 input_tokens: usize, 120 ttft_ms: f64, 121 itl_p50_ms: f64, 122 itl_p95_ms: f64, 123 itl_p99_ms: f64, 124 total_time_ms: f64, 125 tokens_generated: usize, 126 tok_per_sec: f64, 127 success: bool, 128 oracle_match: Option, 129 error: Option, 130 } 131 132 #[derive(Debug, Clone, Serialize)] 133 struct TrialSummary { 134 engine: String, 135 branch_count: usize, 136 repetition: usize, 137 completed_branches: usize, 138 failed_branches: usize, 139 prefix_tokens: usize, 140 ttft_p50_ms: f64, 141 ttft_p95_ms: f64, 142 ttft_p99_ms: f64, 143 itl_p50_ms: f64, 144 itl_p95_ms: f64, 145 aggregate_tokens_per_sec: f64, 146 total_wall_time_ms: f64, 147 pss_mb_before: Option, 148 pss_mb_peak: Option, 149 rss_mb_peak: Option, 150 min_mem_available_mb: Option, 151 } 152 153 fn hash_tokens(token_ids: &[u32]) -> String { 154 let mut hasher = Sha256::new(); 155 for &tid in token_ids { 156 hasher.update(tid.to_le_bytes()); 157 } 158 format!("{:x}", hasher.finalize()) 159 } 160 161 fn calculate_percentile(values: &mut [f64], pct: f64) -> f64 { 162 if values.is_empty() { 163 return 0.0; 164 } 165 values.sort_by(|a, b| a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal)); 166 let idx = ((values.len() as f64 - 1.0) * pct).round() as usize; 167 values[idx.min(values.len() - 1)] 168 } 169 170 fn read_system_mem_available_kb() -> Option { 171 let content = fs::read_to_string("/proc/meminfo").ok()?; 172 for line in content.lines() { 173 if let Some(rest) = line.strip_prefix("MemAvailable:") { 174 return rest 175 .split_whitespace() 176 .next() 177 .and_then(|v| v.parse::().ok()); 178 } 179 } 180 None 181 } 182 183 async fn verify_engine_model( 184 client: &Client, 185 url: &str, 186 expected_model: &str, 187 expected_revision: &str, 188 ) -> Result<(), String> { 189 let endpoint = format!("{}/models", url.trim_end_matches("/")); 190 let res = client 191 .get(&endpoint) 192 .timeout(Duration::from_secs(5)) 193 .send() 194 .await 195 .map_err(|e| format!("Failed to reach engine /v1/models at {}: {}", endpoint, e))?; 196 197 if !res.status().is_success() { 198 return Err(format!( 199 "Engine returned HTTP {} on /v1/models", 200 res.status() 201 )); 202 } 203 204 let body: serde_json::Value = res 205 .json() 206 .await 207 .map_err(|e| format!("Failed to parse /v1/models JSON: {}", e))?; 208 209 let mut found = false; 210 let mut rev_matched = false; 211 let rev_short = &expected_revision[..expected_revision.len().min(8)]; 212 213 if let Some(data) = body.get("data").and_then(|d| d.as_array()) { 214 for m in data { 215 if let Some(id) = m.get("id").and_then(|i| i.as_str()) { 216 if id.contains(expected_model) || expected_model.contains(id) { 217 found = true; 218 if let Some(root) = m.get("root").and_then(|r| r.as_str()) { 219 if root.contains(rev_short) || root.contains(expected_revision) { 220 rev_matched = true; 221 } 222 } 223 if let Some(rev) = m.get("revision").and_then(|r| r.as_str()) { 224 if rev.contains(rev_short) || rev.contains(expected_revision) { 225 rev_matched = true; 226 } 227 } 228 if id.contains(rev_short) || id.contains(expected_revision) { 229 rev_matched = true; 230 } 231 break; 232 } 233 } 234 } 235 } 236 237 if found && rev_matched { 238 Ok(()) 239 } else if found { 240 Err(format!( 241 "Model {} found at {}, but pinned revision {} could not be verified (server response did not contain matching revision or path)", 242 expected_model, endpoint, expected_revision 243 )) 244 } else { 245 Err(format!( 246 "Model {} not found in active engine models list at {}", 247 expected_model, endpoint 248 )) 249 } 250 } 251 252 async fn execute_single_branch( 253 client: Client, 254 url: String, 255 model: String, 256 prefix_tokens: Arc>, 257 branch: BranchSpec, 258 max_tokens: usize, 259 barrier: Arc, 260 ) -> BranchTrialResult { 261 // 1. Construct complete 32K+ input token prompt 262 let mut full_token_ids = Vec::with_capacity(prefix_tokens.len() + branch.token_ids.len()); 263 full_token_ids.extend_from_slice(&prefix_tokens); 264 full_token_ids.extend_from_slice(&branch.token_ids); 265 let input_tokens = full_token_ids.len(); 266 267 // 2. Synchronize all concurrent branches before firing 268 barrier.wait().await; 269 270 let start_time = Instant::now(); 271 let payload = serde_json::json!({ 272 "model": model, 273 "prompt": full_token_ids, 274 "max_tokens": max_tokens, 275 "temperature": 0.0, 276 "stream": true, 277 }); 278 279 let req = client 280 .post(format!("{}/completions", url.trim_end_matches("/"))) 281 .header("Content-Type", "application/json") 282 .json(&payload); 283 284 let res = match req.send().await { 285 Ok(r) => r, 286 Err(e) => { 287 return BranchTrialResult { 288 branch_id: branch.branch_id, 289 category: branch.category, 290 input_tokens, 291 ttft_ms: 0.0, 292 itl_p50_ms: 0.0, 293 itl_p95_ms: 0.0, 294 itl_p99_ms: 0.0, 295 total_time_ms: start_time.elapsed().as_secs_f64() * 1000.0, 296 tokens_generated: 0, 297 tok_per_sec: 0.0, 298 success: false, 299 oracle_match: None, 300 error: Some(e.to_string()), 301 }; 302 } 303 }; 304 305 if !res.status().is_success() { 306 let status = res.status(); 307 let body = res.text().await.unwrap_or_default(); 308 return BranchTrialResult { 309 branch_id: branch.branch_id, 310 category: branch.category, 311 input_tokens, 312 ttft_ms: 0.0, 313 itl_p50_ms: 0.0, 314 itl_p95_ms: 0.0, 315 itl_p99_ms: 0.0, 316 total_time_ms: start_time.elapsed().as_secs_f64() * 1000.0, 317 tokens_generated: 0, 318 tok_per_sec: 0.0, 319 success: false, 320 oracle_match: None, 321 error: Some(format!("HTTP {}: {}", status, body)), 322 }; 323 } 324 325 let mut stream = res.bytes_stream(); 326 let mut first_token_time: Option = None; 327 let mut last_token_time: Option = None; 328 let mut itls: Vec = Vec::new(); 329 let mut tokens_count = 0; 330 let mut generated_text = String::new(); 331 let mut generated_token_ids: Vec = Vec::new(); 332 let mut line_buffer = String::new(); 333 334 while let Some(item) = stream.next().await { 335 match item { 336 Ok(bytes) => { 337 line_buffer.push_str(&String::from_utf8_lossy(&bytes)); 338 while let Some(newline_pos) = line_buffer.find('\n') { 339 let line = line_buffer[..newline_pos].trim().to_string(); 340 line_buffer.drain(..=newline_pos); 341 342 if line.starts_with("data:") { 343 let data = line.trim_start_matches("data:").trim(); 344 if data == "[DONE]" { 345 break; 346 } 347 if let Ok(val) = serde_json::from_str::(data) { 348 let now = Instant::now(); 349 if first_token_time.is_none() { 350 first_token_time = Some(now); 351 } else if let Some(prev) = last_token_time { 352 let itl = (now - prev).as_secs_f64() * 1000.0; 353 itls.push(itl); 354 } 355 last_token_time = Some(now); 356 357 if let Some(choices) = val.get("choices").and_then(|c| c.as_array()) { 358 if let Some(choice) = choices.first() { 359 if let Some(text_delta) = 360 choice.get("text").and_then(|t| t.as_str()) 361 { 362 generated_text.push_str(text_delta); 363 } 364 if let Some(tid) = 365 choice.get("token_id").and_then(|t| t.as_u64()) 366 { 367 generated_token_ids.push(tid as u32); 368 tokens_count += 1; 369 } else if let Some(tids) = 370 choice.get("token_ids").and_then(|t| t.as_array()) 371 { 372 for t in tids { 373 if let Some(id) = t.as_u64() { 374 generated_token_ids.push(id as u32); 375 tokens_count += 1; 376 } 377 } 378 } else { 379 tokens_count += 1; 380 } 381 } 382 } 383 } 384 } 385 } 386 } 387 Err(e) => { 388 return BranchTrialResult { 389 branch_id: branch.branch_id, 390 category: branch.category, 391 input_tokens, 392 ttft_ms: first_token_time 393 .map(|t| (t - start_time).as_secs_f64() * 1000.0) 394 .unwrap_or(0.0), 395 itl_p50_ms: calculate_percentile(&mut itls, 0.50), 396 itl_p95_ms: calculate_percentile(&mut itls, 0.95), 397 itl_p99_ms: calculate_percentile(&mut itls, 0.99), 398 total_time_ms: start_time.elapsed().as_secs_f64() * 1000.0, 399 tokens_generated: tokens_count, 400 tok_per_sec: 0.0, 401 success: false, 402 oracle_match: None, 403 error: Some(e.to_string()), 404 }; 405 } 406 } 407 } 408 409 let total_time_ms = start_time.elapsed().as_secs_f64() * 1000.0; 410 let ttft_ms = first_token_time 411 .map(|t| (t - start_time).as_secs_f64() * 1000.0) 412 .unwrap_or(total_time_ms); 413 let tok_per_sec = if total_time_ms > 0.0 { 414 (tokens_count as f64) / (total_time_ms / 1000.0) 415 } else { 416 0.0 417 }; 418 419 let oracle_match = if let Some(exp) = branch 420 .expected_output_tokens 421 .as_ref() 422 .or(branch.expected_full_tokens.as_ref()) 423 { 424 if !exp.is_empty() && !generated_token_ids.is_empty() { 425 Some(&generated_token_ids == exp) 426 } else { 427 None 428 } 429 } else if let Some(ref exp_16) = branch.expected_first_16_tokens { 430 if !exp_16.is_empty() && generated_token_ids.len() >= exp_16.len() { 431 Some(generated_token_ids[..exp_16.len()] == exp_16[..]) 432 } else { 433 Some(false) 434 } 435 } else if let Some(ref exp_hash) = branch.expected_output_hash { 436 if !exp_hash.is_empty() && !generated_token_ids.is_empty() { 437 Some(hash_tokens(&generated_token_ids) == *exp_hash) 438 } else { 439 None 440 } 441 } else if let Some(exp_first) = branch.expected_first_token { 442 if !generated_token_ids.is_empty() { 443 Some(generated_token_ids[0] == exp_first) 444 } else { 445 Some(false) 446 } 447 } else if let Some(ref exp_text) = branch.expected_output_text { 448 if !exp_text.is_empty() && !generated_text.is_empty() { 449 Some(generated_text.trim() == exp_text.trim()) 450 } else { 451 None 452 } 453 } else { 454 None 455 }; 456 457 BranchTrialResult { 458 branch_id: branch.branch_id, 459 category: branch.category, 460 input_tokens, 461 ttft_ms, 462 itl_p50_ms: calculate_percentile(&mut itls, 0.50), 463 itl_p95_ms: calculate_percentile(&mut itls, 0.95), 464 itl_p99_ms: calculate_percentile(&mut itls, 0.99), 465 total_time_ms, 466 tokens_generated: tokens_count, 467 tok_per_sec, 468 success: true, 469 oracle_match, 470 error: None, 471 } 472 } 473 474 #[tokio::main] 475 async fn main() -> Result<(), Box> { 476 let args = Args::parse(); 477 fs::create_dir_all(&args.output_dir)?; 478 479 println!("Loading manifest from {}...", args.manifest.display()); 480 let manifest_str = fs::read_to_string(&args.manifest)?; 481 let manifest: Manifest = serde_json::from_str(&manifest_str)?; 482 println!( 483 "Manifest loaded: model={}, rev={}, prefix_tokens={}, available_branches={}", 484 manifest.model_id, 485 &manifest.model_revision[..8], 486 manifest.prefix_token_count, 487 manifest.branches.len() 488 ); 489 490 let prefix_tokens = Arc::new(manifest.prefix_token_ids.clone()); 491 492 let branch_counts: Vec = args 493 .branches 494 .split(',') 495 .filter_map(|s| s.trim().parse::().ok()) 496 .collect(); 497 498 let engines: Vec = args 499 .engines 500 .split(',') 501 .map(|s| s.trim().to_lowercase()) 502 .filter(|s| !s.is_empty()) 503 .collect(); 504 505 let mut all_summaries = Vec::new(); 506 let client = Client::builder() 507 .timeout(Duration::from_secs(600)) 508 .build()?; 509 510 for engine in &engines { 511 let engine_url = match engine.as_str() { 512 "aien" => args.aien_url.clone(), 513 "vllm" => args.vllm_url.clone(), 514 other => { 515 eprintln!("Unknown engine {}, skipping", other); 516 continue; 517 } 518 }; 519 520 if args.verify_model_id { 521 print!( 522 "Verifying model {} (rev {}) on engine {} at {}... ", 523 manifest.model_id, 524 &manifest.model_revision[..8], 525 engine, 526 engine_url 527 ); 528 match verify_engine_model( 529 &client, 530 &engine_url, 531 &manifest.model_id, 532 &manifest.model_revision, 533 ) 534 .await 535 { 536 Ok(_) => println!("verified."), 537 Err(e) => { 538 eprintln!("FAILED: {}", e); 539 eprintln!( 540 "Skipping engine {} due to model verification failure.", 541 engine 542 ); 543 continue; 544 } 545 } 546 } 547 548 for &n_branches in &branch_counts { 549 if n_branches > manifest.branches.len() { 550 eprintln!( 551 "Requested branches {} exceeds manifest branches {}, capping", 552 n_branches, 553 manifest.branches.len() 554 ); 555 continue; 556 } 557 558 for rep in 1..=args.repetitions { 559 println!( 560 "--- Running Engine: {}, Branches: {}, Repetition: {}/{} ---", 561 engine, n_branches, rep, args.repetitions 562 ); 563 564 let pss_mb_before = args 565 .engine_pid 566 .and_then(aien_benchmarks::harness::smaps::read_process_tree_smaps) 567 .map(|s| s.pss_mb()); 568 569 // Start continuous 50ms memory sampler 570 let stop_monitor = Arc::new(AtomicBool::new(false)); 571 let mon_stop = stop_monitor.clone(); 572 let mon_pid = args.engine_pid; 573 574 let monitor_task = tokio::spawn(async move { 575 let mut peak_pss: f64 = 0.0; 576 let mut peak_rss: f64 = 0.0; 577 let mut min_avail_kb: u64 = u64::MAX; 578 579 while !mon_stop.load(Ordering::Relaxed) { 580 if let Some(p) = mon_pid { 581 if let Some(snap) = 582 aien_benchmarks::harness::smaps::read_process_tree_smaps(p) 583 { 584 if snap.pss_mb() > peak_pss { 585 peak_pss = snap.pss_mb(); 586 } 587 if snap.rss_mb() > peak_rss { 588 peak_rss = snap.rss_mb(); 589 } 590 } 591 } 592 if let Some(avail) = read_system_mem_available_kb() { 593 if avail < min_avail_kb { 594 min_avail_kb = avail; 595 } 596 } 597 tokio::time::sleep(Duration::from_millis(50)).await; 598 } 599 600 (peak_pss, peak_rss, min_avail_kb) 601 }); 602 603 let barrier = Arc::new(Barrier::new(n_branches)); 604 let mut tasks = Vec::with_capacity(n_branches); 605 606 let trial_start = Instant::now(); 607 for i in 0..n_branches { 608 let branch = manifest.branches[i].clone(); 609 let b_client = client.clone(); 610 let b_url = engine_url.clone(); 611 let b_model = manifest.model_id.clone(); 612 let b_prefix = prefix_tokens.clone(); 613 let b_barrier = barrier.clone(); 614 let max_tok = args.max_tokens; 615 616 tasks.push(tokio::spawn(async move { 617 execute_single_branch( 618 b_client, b_url, b_model, b_prefix, branch, max_tok, b_barrier, 619 ) 620 .await 621 })); 622 } 623 624 let mut branch_results = Vec::with_capacity(n_branches); 625 for task in tasks { 626 match task.await { 627 Ok(res) => branch_results.push(res), 628 Err(e) => eprintln!("Task join error: {}", e), 629 } 630 } 631 632 let wall_time_ms = trial_start.elapsed().as_secs_f64() * 1000.0; 633 634 // Stop memory sampler and extract measured peaks 635 stop_monitor.store(true, Ordering::Relaxed); 636 let (peak_pss, peak_rss, min_avail_kb) = 637 monitor_task.await.unwrap_or((0.0, 0.0, 0)); 638 639 let trial_filename = format!("trial-{}-{}-rep{}.jsonl", engine, n_branches, rep); 640 let trial_path = args.output_dir.join(&trial_filename); 641 let mut file = File::create(&trial_path)?; 642 for b in &branch_results { 643 writeln!(file, "{}", serde_json::to_string(b)?)?; 644 } 645 646 let completed = branch_results.iter().filter(|b| b.success).count(); 647 let failed = branch_results.len() - completed; 648 649 let mut ttft_vec: Vec = branch_results 650 .iter() 651 .filter(|b| b.success) 652 .map(|b| b.ttft_ms) 653 .collect(); 654 655 let mut itl_vec: Vec = branch_results 656 .iter() 657 .filter(|b| b.success) 658 .map(|b| b.itl_p50_ms) 659 .collect(); 660 661 let total_tokens: usize = branch_results 662 .iter() 663 .filter(|b| b.success) 664 .map(|b| b.tokens_generated) 665 .sum(); 666 667 let agg_tok_per_sec = if wall_time_ms > 0.0 { 668 (total_tokens as f64) / (wall_time_ms / 1000.0) 669 } else { 670 0.0 671 }; 672 673 let summary = TrialSummary { 674 engine: engine.clone(), 675 branch_count: n_branches, 676 repetition: rep, 677 completed_branches: completed, 678 failed_branches: failed, 679 prefix_tokens: manifest.prefix_token_count, 680 ttft_p50_ms: calculate_percentile(&mut ttft_vec, 0.50), 681 ttft_p95_ms: calculate_percentile(&mut ttft_vec, 0.95), 682 ttft_p99_ms: calculate_percentile(&mut ttft_vec, 0.99), 683 itl_p50_ms: calculate_percentile(&mut itl_vec, 0.50), 684 itl_p95_ms: calculate_percentile(&mut itl_vec, 0.95), 685 aggregate_tokens_per_sec: agg_tok_per_sec, 686 total_wall_time_ms: wall_time_ms, 687 pss_mb_before, 688 pss_mb_peak: if peak_pss > 0.0 { Some(peak_pss) } else { None }, 689 rss_mb_peak: if peak_rss > 0.0 { Some(peak_rss) } else { None }, 690 min_mem_available_mb: if min_avail_kb < u64::MAX { 691 Some(min_avail_kb as f64 / 1024.0) 692 } else { 693 None 694 }, 695 }; 696 697 println!( 698 " -> Completed: {}/{}, TTFT p50: {:.2}ms, ITL p50: {:.2}ms, Agg tok/s: {:.2}, Peak PSS: {:.2} MB", 699 completed, 700 n_branches, 701 summary.ttft_p50_ms, 702 summary.itl_p50_ms, 703 summary.aggregate_tokens_per_sec, 704 summary.pss_mb_peak.unwrap_or(0.0) 705 ); 706 707 all_summaries.push(summary); 708 } 709 } 710 } 711 712 let summary_path = args.output_dir.join("summary.json"); 713 let mut file = File::create(&summary_path)?; 714 writeln!(file, "{}", serde_json::to_string_pretty(&all_summaries)?)?; 715 println!( 716 "Benchmark run complete. Summary saved to {}", 717 summary_path.display() 718 ); 719 720 Ok(()) 721 }