light_heap/
bench.rs

1#[macro_export]
2macro_rules! bench_sbf_start {
3    ($custom_msg:literal) => {
4        // Conditionally compile only if on Solana OS and feature "bench-sbf" is enabled
5        #[cfg(all(target_os = "solana", feature = "bench-sbf"))]
6        {
7            // Log the total heap with a custom message indicating the start
8            light_heap::GLOBAL_ALLOCATOR
9                .log_total_heap(format!("{}_start_bench_cu", $custom_msg).as_str());
10            // Log the number of compute units used
11            anchor_lang::solana_program::log::sol_log_compute_units();
12        }
13    };
14}
15
16#[macro_export]
17macro_rules! bench_sbf_end {
18    ($custom_msg:literal) => {
19        // Conditionally compile only if on Solana OS and feature "bench-sbf" is enabled
20        #[cfg(all(target_os = "solana", feature = "bench-sbf"))]
21        {
22            anchor_lang::solana_program::log::sol_log_compute_units();
23            // Log the total heap with a custom message indicating the end
24            light_heap::GLOBAL_ALLOCATOR
25                .log_total_heap(format!("{}_end_bench_cu", $custom_msg).as_str());
26            // Log the number of compute units used
27        }
28    };
29}