bench_goldilocks_mul/lib.rs
1//! Goldilocks-multiplication-only benchmark — runs `MUL_COUNT`
2//! multiplications in a chain so each iteration's input depends on
3//! the previous output. Decomposes the field-arithmetic cost out of
4//! the mini-verifier composite workload so per-VM differences in
5//! handling `u64 * u64 -> u128 -> mod p_G` can be seen in isolation.
6
7#![cfg_attr(target_os = "none", no_std)]
8
9use subsoil as _;
10
11use gp::{canonical, mul};
12
13const MUL_COUNT: u32 = 100_000;
14const SEED: u64 = 0x123456789abcdef0;
15const MULTIPLIER: u64 = 0x9E3779B97F4A7C15;
16
17pub fn goldilocks_mul_bench() -> u32 {
18 let mut acc = SEED;
19 let mut i = 0;
20 while i < MUL_COUNT {
21 acc = mul(acc, MULTIPLIER);
22 i += 1;
23 }
24 (canonical(acc) & 0xFFFF_FFFF) as u32
25}