summaryrefslogtreecommitdiffstats
path: root/src/profiler.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/profiler.rs')
-rw-r--r--src/profiler.rs52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/profiler.rs b/src/profiler.rs
index 7527839a..9543db3c 100644
--- a/src/profiler.rs
+++ b/src/profiler.rs
@@ -1,39 +1,39 @@
/// helper struct to not pollute main with feature flags shenanigans for the profiler
/// also we make sure to generate a flamegraph on program exit
pub struct Profiler {
- #[cfg(feature = "pprof")]
- #[cfg(not(windows))]
- guard: pprof::ProfilerGuard<'static>,
+ #[cfg(feature = "pprof")]
+ #[cfg(not(windows))]
+ guard: pprof::ProfilerGuard<'static>,
}
impl Profiler {
- #[allow(clippy::missing_const_for_fn)]
- pub fn new() -> Self {
- Self {
- #[cfg(feature = "pprof")]
- #[cfg(not(windows))]
- guard: pprof::ProfilerGuard::new(100)
- .expect("profiler launch error"),
- }
- }
+ #[allow(clippy::missing_const_for_fn)]
+ pub fn new() -> Self {
+ Self {
+ #[cfg(feature = "pprof")]
+ #[cfg(not(windows))]
+ guard: pprof::ProfilerGuard::new(100)
+ .expect("profiler launch error"),
+ }
+ }
- #[allow(clippy::unused_self)]
- fn report(&mut self) {
- #[cfg(feature = "pprof")]
- #[cfg(not(windows))]
- if let Ok(report) = self.guard.report().build() {
- let file = std::fs::File::create("flamegraph.svg")
- .expect("flamegraph file err");
+ #[allow(clippy::unused_self)]
+ fn report(&mut self) {
+ #[cfg(feature = "pprof")]
+ #[cfg(not(windows))]
+ if let Ok(report) = self.guard.report().build() {
+ let file = std::fs::File::create("flamegraph.svg")
+ .expect("flamegraph file err");
- report.flamegraph(&file).expect("flamegraph write err");
+ report.flamegraph(&file).expect("flamegraph write err");
- log::info!("profiler reported");
- }
- }
+ log::info!("profiler reported");
+ }
+ }
}
impl Drop for Profiler {
- fn drop(&mut self) {
- self.report();
- }
+ fn drop(&mut self) {
+ self.report();
+ }
}