Skip to content

Commit

Permalink
don't expose profiling macros, add some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Aug 10, 2023
1 parent 2bc5e89 commit b2e2a60
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions triton-vm/src/fri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 13 additions & 3 deletions triton-vm/src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,10 @@ impl Display for Report {
}
}

#[macro_export]
/// Start a profiling task.
/// Requires an `Option<Profiler>` 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() {
Expand All @@ -614,17 +617,23 @@ 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() {
profiler.stop($s);
}
};
}
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() {
Expand All @@ -637,6 +646,7 @@ macro_rules! prof_itr0 {
}
};
}
pub(crate) use prof_itr0;

#[cfg(test)]
pub mod triton_profiler_tests {
Expand Down
4 changes: 2 additions & 2 deletions triton-vm/src/shared_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions triton-vm/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions triton-vm/src/table/master_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b2e2a60

Please sign in to comment.