diff --git a/triton-vm/src/fri.rs b/triton-vm/src/fri.rs index d7620ccd..75c4b9c2 100644 --- a/triton-vm/src/fri.rs +++ b/triton-vm/src/fri.rs @@ -21,8 +21,8 @@ use twenty_first::util_types::merkle_tree::MerkleTree; use twenty_first::util_types::merkle_tree_maker::MerkleTreeMaker; use crate::arithmetic_domain::ArithmeticDomain; -use crate::prof_start; -use crate::prof_stop; +use crate::profiler::prof_start; +use crate::profiler::prof_stop; use crate::profiler::TritonProfiler; use crate::proof_item::FriResponse; use crate::proof_item::ProofItem; diff --git a/triton-vm/src/profiler.rs b/triton-vm/src/profiler.rs index b968d50a..d4930919 100644 --- a/triton-vm/src/profiler.rs +++ b/triton-vm/src/profiler.rs @@ -601,7 +601,10 @@ impl Display for Report { } } -#[macro_export] +/// Start a profiling task. +/// Requires an `Option` as first argument. Does nothing if this is `None`. +/// The second argument is the name of the task. +/// The third argument is an optional task category. macro_rules! prof_start { ($p: ident, $s : expr, $c : expr) => { if let Some(profiler) = $p.as_mut() { @@ -614,8 +617,11 @@ macro_rules! prof_start { } }; } +pub(crate) use prof_start; -#[macro_export] +/// Stop a profiling task. Requires the same arguments as [`prof_start`], except that the task's +/// category (if any) is inferred. Notably, the task's name needs to be an exact match to prevent +/// the accidental stopping of a different task. macro_rules! prof_stop { ($p: ident, $s : expr) => { if let Some(profiler) = $p.as_mut() { @@ -623,8 +629,11 @@ macro_rules! prof_stop { } }; } +pub(crate) use prof_stop; -#[macro_export] +/// Profile one iteration of a loop. Requires the same arguments as [`prof_start`]. +/// This macro should be invoked inside the loop in question. +/// The profiling of the loop has to be stopped with [`prof_stop`] after the loop. macro_rules! prof_itr0 { ($p : ident, $s : expr, $c : expr) => { if let Some(profiler) = $p.as_mut() { @@ -637,6 +646,7 @@ macro_rules! prof_itr0 { } }; } +pub(crate) use prof_itr0; #[cfg(test)] pub mod triton_profiler_tests { diff --git a/triton-vm/src/shared_tests.rs b/triton-vm/src/shared_tests.rs index a500d7db..8aecc35f 100644 --- a/triton-vm/src/shared_tests.rs +++ b/triton-vm/src/shared_tests.rs @@ -11,8 +11,8 @@ use anyhow::Result; use twenty_first::shared_math::b_field_element::BFieldElement; use crate::aet::AlgebraicExecutionTrace; -use crate::prof_start; -use crate::prof_stop; +use crate::profiler::prof_start; +use crate::profiler::prof_stop; use crate::profiler::TritonProfiler; use crate::program::Program; use crate::proof::Claim; diff --git a/triton-vm/src/stark.rs b/triton-vm/src/stark.rs index 703b2a27..7c5871ee 100644 --- a/triton-vm/src/stark.rs +++ b/triton-vm/src/stark.rs @@ -31,9 +31,9 @@ use crate::aet::AlgebraicExecutionTrace; use crate::arithmetic_domain::ArithmeticDomain; use crate::ensure_eq; use crate::fri::Fri; -use crate::prof_itr0; -use crate::prof_start; -use crate::prof_stop; +use crate::profiler::prof_itr0; +use crate::profiler::prof_start; +use crate::profiler::prof_stop; use crate::profiler::TritonProfiler; use crate::proof::Claim; use crate::proof::Proof; diff --git a/triton-vm/src/table/master_table.rs b/triton-vm/src/table/master_table.rs index 43651fdb..6a44d168 100644 --- a/triton-vm/src/table/master_table.rs +++ b/triton-vm/src/table/master_table.rs @@ -32,8 +32,8 @@ use twenty_first::util_types::merkle_tree_maker::MerkleTreeMaker; use crate::aet::AlgebraicExecutionTrace; use crate::arithmetic_domain::ArithmeticDomain; -use crate::prof_start; -use crate::prof_stop; +use crate::profiler::prof_start; +use crate::profiler::prof_stop; use crate::profiler::TritonProfiler; use crate::stark::MTMaker; use crate::stark::StarkHasher;