Skip to main content

count_ops

Function count_ops 

Source
pub fn count_ops<R>(f: impl FnOnce() -> R) -> (R, u64)
Expand description

Run f with arithmetic-op counting active and return (f's result, arithmetic IR ops executed). The count is every BinOp / UnOp / Fma the reference interpreter evaluates during f: a backend-agnostic dynamic operation count.

Re-entrant-safe: a nested count_ops reports its own inner ops AND propagates them to the enclosing scope, so an outer scope’s total still includes work done inside inner scopes.