diff options
| author | Kamen Mladenov <kamen@syndamia.com> | 2025-02-10 10:52:35 +0200 |
|---|---|---|
| committer | Kamen Mladenov <kamen@syndamia.com> | 2025-02-10 10:52:35 +0200 |
| commit | ceed1b4a33a9b8d0580bd35493f34102ae59d184 (patch) | |
| tree | ecdc4757e90e244f9da30e9737ff8aacf6a0a668 | |
| parent | bb7f09ea36d5ba02fe5648941de51aa5765d4010 (diff) | |
| download | zkVMs-benchmarks-ceed1b4a33a9b8d0580bd35493f34102ae59d184.tar zkVMs-benchmarks-ceed1b4a33a9b8d0580bd35493f34102ae59d184.tar.gz zkVMs-benchmarks-ceed1b4a33a9b8d0580bd35493f34102ae59d184.zip | |
feat(zkvms_host_io): Allow appending to metric_output file
| -rw-r--r-- | zkvms_host_io/input_macros/src/lib.rs | 9 | ||||
| -rw-r--r-- | zkvms_host_io/src/lib.rs | 5 |
2 files changed, 12 insertions, 2 deletions
diff --git a/zkvms_host_io/input_macros/src/lib.rs b/zkvms_host_io/input_macros/src/lib.rs index 8d7c2fc..e2982ca 100644 --- a/zkvms_host_io/input_macros/src/lib.rs +++ b/zkvms_host_io/input_macros/src/lib.rs @@ -114,7 +114,7 @@ pub fn benchmarkable(item: TokenStream) -> TokenStream { format!(r#" {{ use std::time::Instant; - use std::fs::File; + use std::fs::OpenOptions; use std::io::Write; let mut starts = Vec::new(); @@ -148,7 +148,12 @@ pub fn benchmarkable(item: TokenStream) -> TokenStream { output += &format!("repeats,{{}}\naverage,{{average}}\n", run_info.repeats); if let Some(file) = run_info.output_file {{ - let mut outfile = File::create(file).unwrap(); + let mut outfile = OpenOptions::new() + .write(true) + .create(true) + .append(run_info.append) + .open(file) + .unwrap(); write!(outfile, "{{}}", output); }} else {{ diff --git a/zkvms_host_io/src/lib.rs b/zkvms_host_io/src/lib.rs index fbdd8f9..3de8c5e 100644 --- a/zkvms_host_io/src/lib.rs +++ b/zkvms_host_io/src/lib.rs @@ -30,6 +30,9 @@ struct Cli { #[arg(short, long, requires = "benchmark")] metrics_output: Option<String>, + + #[arg(short, long, requires = "benchmark")] + append: bool, } #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] @@ -46,6 +49,7 @@ pub struct RunWith { pub repeats: usize, pub millis: bool, pub output_file: Option<String>, + pub append: bool, pub input: Input, pub public_input: PublicInput, @@ -98,6 +102,7 @@ pub fn read_args() -> RunWith { repeats: cli.repeat.unwrap_or(1), millis: cli.millis, output_file: cli.metrics_output, + append: cli.append, input, public_input, |
