cargo nexus host benchmark
, a new Rust benchmark
project directory is created with the following structure:
src/guest/src/main.rs
, and the host program is located in src/main.rs
.
ExitSuccess
, it means the guest program execution completed successfully as we expect it to.
src/main.rs
as follows:
src/guest/src/main.rs
will be a simple Fibonacci program: it receives an public input n
and returns fib(n+1)
as the public output.
The public input is marked as #[cfg_attr(target_arch = "riscv32", nexus_rt::public_input(x))]
, which means when proving the public input will be passed as the guest program variable x
at runtime.
The public output is the return value of the #[nexus_rt::main]
function, which is fib(n+1)
in this case.
bench.sh
, remember to make it executable with chmod +x bench.sh
, and run it with ./bench.sh
.
n-th Fibonacci | Compile (ms) | Prove (ms) | Verify (ms) | Total Time (ms) | Proof size (bytes) |
---|---|---|---|---|---|
0 | 161 | 1592 | 11 | 1764 | 51968 |
1 | 149 | 1522 | 11 | 1684 | 51968 |
2 | 148 | 1514 | 11 | 1675 | 51968 |
3 | 151 | 1538 | 11 | 1701 | 51440 |
5 | 151 | 1477 | 12 | 1641 | 51968 |
8 | 128 | 1465 | 11 | 1606 | 46008 |
13 | 136 | 1454 | 11 | 1602 | 49304 |
21 | 138 | 1440 | 12 | 1591 | 49880 |
34 | 149 | 1551 | 12 | 1713 | 51968 |
55 | 149 | 1422 | 13 | 1584 | 51440 |
89 | 151 | 1432 | 12 | 1596 | 51440 |
144 | 153 | 1427 | 11 | 1593 | 49460 |
233 | 149 | 1434 | 12 | 1596 | 50384 |
377 | 138 | 1417 | 11 | 1567 | 50368 |
610 | 148 | 1453 | 11 | 1613 | 51968 |
987 | 150 | 1510 | 12 | 1673 | 49280 |
1597 | 149 | 1443 | 11 | 1604 | 50384 |
2584 | 146 | 1460 | 13 | 1620 | 50864 |
4181 | 147 | 1449 | 11 | 1610 | 51968 |
6765 | 149 | 1440 | 11 | 1602 | 51968 |
n-th Fibonacci | Compile (ms) | Prove (ms) | Verify (ms) | Total Time (ms) | Proof size (bytes) |
---|---|---|---|---|---|
200 | 156 | 17416 | 189 | 17762 | 58544 |
201 | 154 | 17179 | 183 | 17518 | 59904 |
202 | 152 | 17468 | 183 | 17804 | 59248 |
204 | 158 | 17238 | 181 | 17579 | 59248 |
205 | 151 | 17242 | 184 | 17579 | 57920 |