Skip to content

Commit

Permalink
Benchmark AllocProfiler internals
Browse files Browse the repository at this point in the history
  • Loading branch information
nvzqz committed Dec 11, 2023
1 parent 43d2ddc commit c605ab7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal_benches/benches/internals.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use divan::AllocProfiler;

#[global_allocator]
static GLOBAL_ALLOC: AllocProfiler = AllocProfiler::system();

fn main() {
divan::main();
}
15 changes: 15 additions & 0 deletions src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,18 @@ impl<T> AllocOpMap<T> {
&self.values[op as usize]
}
}

#[cfg(feature = "internal_benches")]
mod thread_info {
use super::*;

#[crate::bench(crate = crate)]
fn current() -> &'static ThreadAllocInfo {
AllocProfiler::system().current_thread_info()
}

#[crate::bench(crate = crate)]
fn try_current() -> Option<&'static ThreadAllocInfo> {
CURRENT_THREAD_INFO.get()
}
}

0 comments on commit c605ab7

Please sign in to comment.