Skip to content

Commit

Permalink
dev: add mhz for speed of tracer and prover
Browse files Browse the repository at this point in the history
  • Loading branch information
Eikix committed Jan 17, 2025
1 parent 884a1b1 commit 77ca2cb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions crates/brainfuck_prover/src/bin/brainfuck_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
fs::{self, File},
io::{stdin, stdout, Write},
path::PathBuf,
time::Instant,
};
use stwo_prover::core::prover::ProvingError;

Expand Down Expand Up @@ -96,10 +97,14 @@ fn prove(execution_config: ExecutionConfig) -> Result<(), ProvingError> {
};

tracing::info!("Provide inputs if any:");
let trace_start = Instant::now();
bf_vm.execute().unwrap();

let trace = bf_vm.trace();
tracing::info!("Steps: {}", trace.len());
let trace_duration = trace_start.elapsed();
let steps = trace.len();
let trace_mhz = (steps as f64) / trace_duration.as_secs_f64() / 1_000_000.0;
tracing::info!("Steps: {}", steps);
tracing::info!("Trace generation speed: {:.2} MHz", trace_mhz);

if execution_config.trace {
tracing::info!("Execution Trace");
Expand All @@ -112,8 +117,12 @@ fn prove(execution_config: ExecutionConfig) -> Result<(), ProvingError> {
}

tracing::info!("Proof Generation");
let proof_start = Instant::now();
let bf_proof = prove_brainfuck(&bf_vm)?;
let proof_duration = proof_start.elapsed();
let proof_mhz = (steps as f64) / proof_duration.as_secs_f64() / 1_000_000.0;
tracing::info!("Proof successfully generated!");
tracing::info!("Proof generation speed: {:.2} MHz", proof_mhz);

if let Some(path) = execution_config.output {
tracing::info!("Exporting Proof");
Expand All @@ -125,6 +134,10 @@ fn prove(execution_config: ExecutionConfig) -> Result<(), ProvingError> {
println!("{bf_proof:#?}");
}

tracing::info!("Trace execution time: {:.2}s", trace_duration.as_secs_f64());
tracing::info!("Proof generation time: {:.2}s", proof_duration.as_secs_f64());
tracing::info!("Total execution time: {:.2}s", (trace_duration + proof_duration).as_secs_f64());

Ok(())
}

Expand Down

0 comments on commit 77ca2cb

Please sign in to comment.