Skip to content

Commit

Permalink
Add execute datasheet
Browse files Browse the repository at this point in the history
  • Loading branch information
flaub committed Apr 29, 2024
1 parent 8670588 commit 8fbb8a0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions risc0/zkvm/examples/datasheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct Args {

#[derive(Eq, PartialEq, Subcommand, Sequence)]
enum Command {
Execute,
Composite,
Lift,
Join,
Expand Down Expand Up @@ -106,6 +107,7 @@ impl Datasheet {

fn run_cmd(&mut self, cmd: Command) {
match cmd {
Command::Execute => self.execute(),
Command::Composite => self.composite(),
Command::Lift => self.lift(),
Command::Join => self.join(),
Expand All @@ -118,6 +120,31 @@ impl Datasheet {
}
}

fn execute(&mut self) {
let env = ExecutorEnv::builder()
.write(&SpecWithIters(BenchmarkSpec::SimpleLoop, 128 * 1024))
.unwrap()
.build()
.unwrap();

let mut exec = ExecutorImpl::from_elf(env, BENCH_ELF).unwrap();

let start = Instant::now();
let session = exec.run().unwrap();
let duration = start.elapsed();

let throughput = (session.user_cycles as f32) / duration.as_secs_f32();
self.results.push(PerformanceData {
name: "execute".into(),
hashfn: "N/A".into(),
cycles: session.user_cycles,
duration,
ram: 0,
seal: 0,
throughput,
});
}

fn composite(&mut self) {
for hashfn in ["sha-256", "poseidon2"] {
let mut opts = ProverOpts::default();
Expand Down

0 comments on commit 8fbb8a0

Please sign in to comment.