Profiling tweaks
This commit is contained in:
@@ -20,3 +20,8 @@ jemalloc-ctl = { version = "0.3.3", optional = true }
|
|||||||
[features]
|
[features]
|
||||||
jemalloc = [ "jemallocator", "jemalloc-ctl" ]
|
jemalloc = [ "jemallocator", "jemalloc-ctl" ]
|
||||||
cpu_profiler = []
|
cpu_profiler = []
|
||||||
|
|
||||||
|
# Uncomment to enable for the whole crate graph
|
||||||
|
# default = [ "backtrace" ]
|
||||||
|
# default = [ "jemalloc" ]
|
||||||
|
# default = [ "cpu_profiler" ]
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ pub struct Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Scope {
|
impl Scope {
|
||||||
|
#[must_use]
|
||||||
pub fn enter() -> Scope {
|
pub fn enter() -> Scope {
|
||||||
let prev = IN_SCOPE.with(|slot| std::mem::replace(&mut *slot.borrow_mut(), true));
|
let prev = IN_SCOPE.with(|slot| std::mem::replace(&mut *slot.borrow_mut(), true));
|
||||||
Scope { prev }
|
Scope { prev }
|
||||||
@@ -78,6 +79,7 @@ pub struct CpuProfiler {
|
|||||||
_private: (),
|
_private: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn cpu_profiler() -> CpuProfiler {
|
pub fn cpu_profiler() -> CpuProfiler {
|
||||||
#[cfg(feature = "cpu_profiler")]
|
#[cfg(feature = "cpu_profiler")]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn timeit(label: &'static str) -> impl Drop {
|
pub fn timeit(label: &'static str) -> impl Drop {
|
||||||
struct Guard {
|
struct Guard {
|
||||||
label: &'static str,
|
label: &'static str,
|
||||||
|
|||||||
Reference in New Issue
Block a user