diff options
| author | Kamen Mladenov <kamen@syndamia.com> | 2025-05-02 10:24:47 +0300 |
|---|---|---|
| committer | Kamen Mladenov <kamen@syndamia.com> | 2025-05-02 15:32:54 +0300 |
| commit | 1a2ad5528f7a61390c40c0b6f56fa507923d09f5 (patch) | |
| tree | 713b8e86674a34b3a6b6d65062709f192f5b894c /zkvms_guest_io/src | |
| parent | eefb57f2c035be1a398f630dd8cfed8b4ccbe348 (diff) | |
| download | zkVMs-benchmarks-1a2ad5528f7a61390c40c0b6f56fa507923d09f5.tar zkVMs-benchmarks-1a2ad5528f7a61390c40c0b6f56fa507923d09f5.tar.gz zkVMs-benchmarks-1a2ad5528f7a61390c40c0b6f56fa507923d09f5.zip | |
chore: cargo fmt
Diffstat (limited to 'zkvms_guest_io/src')
| -rw-r--r-- | zkvms_guest_io/src/main.rs | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/zkvms_guest_io/src/main.rs b/zkvms_guest_io/src/main.rs index 4d9b378..4dfd1ae 100644 --- a/zkvms_guest_io/src/main.rs +++ b/zkvms_guest_io/src/main.rs @@ -1,11 +1,11 @@ use clap::Parser; -use std::process::{Command, Stdio}; +use itertools::Itertools; use json::{object, parse, JsonValue, Null}; -use std::io::{Error, Write}; -use std::fs::{read_to_string, OpenOptions}; use smbioslib::*; +use std::fs::{read_to_string, OpenOptions}; +use std::io::{Error, Write}; +use std::process::{Command, Stdio}; use sysinfo::System; -use itertools::Itertools; /// A CLI tool for running and benchmarking a guest program inside all /// supported zkVMs. @@ -41,7 +41,7 @@ fn run_command(zkvm_guest_command: &str, operation: &str) -> Result<std::process .args(["--no-container", "--output", COMMAND_LOG_PATH, "--"]) .args([zkvm_guest_command, operation]) .arg("--benchmark") - .args([ "--metrics-output", METRICS_TEMP_OUTPUT_PATH ]) + .args(["--metrics-output", METRICS_TEMP_OUTPUT_PATH]) .stdout(Stdio::piped()) .output() } @@ -79,7 +79,11 @@ fn main() { // Always available information let sys = System::new_all(); - let cpus = sys.cpus().into_iter().unique_by(|c| c.brand()).collect::<Vec<_>>(); + let cpus = sys + .cpus() + .into_iter() + .unique_by(|c| c.brand()) + .collect::<Vec<_>>(); for cpu in cpus { let mut hcpu = JsonValue::new_object(); @@ -99,16 +103,17 @@ fn main() { // Either login through another TTY as root, or use `machinectl shell root@` if let Ok(sys) = table_load_from_device() { // Fix CPU core counts - let cpus = sys.filter(|cpu: &SMBiosProcessorInformation| true).collect::<Vec<SMBiosProcessorInformation>>(); + let cpus = sys + .filter(|cpu: &SMBiosProcessorInformation| true) + .collect::<Vec<SMBiosProcessorInformation>>(); for mut hcpu in runs["hardware"]["cpu"].members_mut() { - if let Some(cpu) = cpus.iter().find(|cpu| + if let Some(cpu) = cpus.iter().find(|cpu| { if let Some(ver) = cpu.processor_version().ok() { ver.trim() == hcpu["model"].to_string().trim() - } - else { + } else { false } - ) { + }) { if let Some(CoreCount::Count(cores)) = cpu.core_count() { hcpu["cores"] = cores.into(); } @@ -168,7 +173,8 @@ fn main() { println!("Command failed!"); } - let stdout = String::from_utf8(output.stdout).expect("failed to convert stdout to String"); + let stdout = + String::from_utf8(output.stdout).expect("failed to convert stdout to String"); println!("{stdout}"); if !output.stderr.is_empty() { @@ -192,15 +198,14 @@ fn main() { continue; } - let raw_data = &read_to_string(METRICS_TEMP_OUTPUT_PATH) - .ok() - .unwrap(); + let raw_data = &read_to_string(METRICS_TEMP_OUTPUT_PATH).ok().unwrap(); run[operation] = json::parse(raw_data).unwrap(); - run[operation]["memory"] = get_runexec_value(&stdout, "memory", 'B').parse::<u64>().unwrap().into(); + run[operation]["memory"] = get_runexec_value(&stdout, "memory", 'B') + .parse::<u64>() + .unwrap() + .into(); - let proofSize = &read_to_string(PROOF_SIZE_FILE_PATH) - .ok() - .unwrap(); + let proofSize = &read_to_string(PROOF_SIZE_FILE_PATH).ok().unwrap(); run[operation]["proofSize"] = proofSize.parse::<u64>().unwrap().into(); } |
