nova_interpreter/
utils.rs

1pub mod interner;
2
3use super::engine::state::State;
4
5/// Helper type for function that can return an error
6pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
7
8/// Helper type for builtin functions to pass the engine state
9pub type PrimitiveFn = Box<dyn Fn(&mut State, usize)>;
10
11/// Run a function and return both the function results
12/// and the amount of time it took to run the function
13#[macro_export]
14macro_rules! time_fn {
15    ($f:block) => {{
16        let pre_run_time = std::time::Instant::now();
17
18        let result = $f;
19
20        let post_run_time = std::time::Instant::now();
21
22        let duration = post_run_time - pre_run_time;
23
24        (result, duration)
25    }};
26}