aboutsummaryrefslogtreecommitdiff
path: root/zkvms_host_io/src/lib.rs
diff options
context:
space:
mode:
authorKamen Mladenov <kamen@syndamia.com>2025-04-30 17:25:15 +0300
committerKamen Mladenov <kamen@syndamia.com>2025-05-02 15:32:54 +0300
commiteefb57f2c035be1a398f630dd8cfed8b4ccbe348 (patch)
tree598cc4a5d784addf59bad7323018260b977ed6c2 /zkvms_host_io/src/lib.rs
parent400c41f4f408aee6002489633914cd74ca888ff4 (diff)
downloadzkVMs-benchmarks-eefb57f2c035be1a398f630dd8cfed8b4ccbe348.tar
zkVMs-benchmarks-eefb57f2c035be1a398f630dd8cfed8b4ccbe348.tar.gz
zkVMs-benchmarks-eefb57f2c035be1a398f630dd8cfed8b4ccbe348.zip
feat(zkvms_guest_io): Output proof size
In each zkVM we'll write the size to /tmp/proof_size and then guest_io will read that value and place it inside our metrics output. This is not the most elegant, and in certain zkVMs the file output is a part of the benchmark timing, but it will have to do.
Diffstat (limited to 'zkvms_host_io/src/lib.rs')
-rw-r--r--zkvms_host_io/src/lib.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/zkvms_host_io/src/lib.rs b/zkvms_host_io/src/lib.rs
index ee66bae..a3249a0 100644
--- a/zkvms_host_io/src/lib.rs
+++ b/zkvms_host_io/src/lib.rs
@@ -21,6 +21,7 @@ static DEFAULT_PUBLIC_INPUT: &str =
static DEFAULT_PRIVATE_INPUT: &str =
include_str!(concat!(env!("INPUTS_DIR"), "/default_private_input.toml"));
static DEFAULT_ENV: &str = include_str!(concat!(env!("INPUTS_DIR"), "/default.env"));
+static PROOF_SIZE_FILE_PATH: &str = "/tmp/proof_size";
/// A CLI tool for running and benchmarking guest programs inside a zkVM
/// environment.
@@ -153,6 +154,14 @@ pub fn read_args() -> RunWith {
}
}
+pub fn output_proof_size<T>(proof: &T) {
+ output_proof_size_raw(std::mem::size_of_val(proof));
+}
+
+pub fn output_proof_size_raw(size: usize) {
+ std::fs::write(PROOF_SIZE_FILE_PATH, size.to_string()).expect(&format!("Couldn't write proof size to \"{PROOF_SIZE_FILE_PATH}\"!"));
+}
+
fn mean(xs: &Vec<f32>) -> f32 {
if xs.len() == 1 {
xs[0]