Skip to main content

airbender_guest/
cycle.rs

1//! Development-only helpers for placing cycle markers in guest code.
2
3/// Emit a cycle marker boundary recognized by the transpiler runner.
4///
5/// Cycle markers are intended for local transpiler profiling. They should not
6/// be used in programs that will be proved with the real CPU/GPU proving path.
7#[inline(always)]
8pub fn marker() {
9    airbender_rt::sys::emit_cycle_marker();
10}
11
12/// Record the cumulative counters around one guest code region.
13#[inline(always)]
14pub fn record_cycles<T>(f: impl FnOnce() -> T) -> T {
15    marker();
16    let result = f();
17    marker();
18    result
19}