aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zkvms_host_io/input_macros/src/lib.rs9
-rw-r--r--zkvms_host_io/src/lib.rs5
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,