mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-28 19:44:14 +03:00
fix windows pprof build
This commit is contained in:
parent
972f071fe4
commit
8f1a1a008a
@ -40,9 +40,7 @@ serde = "1.0"
|
||||
anyhow = "1.0.31"
|
||||
unicode-width = "0.1"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
pprof = { version = "0.3", features = ["flamegraph"], optional = true }
|
||||
[target.'cfg(macos)'.dependencies]
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
pprof = { version = "0.3", features = ["flamegraph"], optional = true }
|
||||
|
||||
[badges]
|
||||
|
@ -2,6 +2,7 @@
|
||||
/// also we make sure to generate a flamegraph on program exit
|
||||
pub struct Profiler {
|
||||
#[cfg(feature = "pprof")]
|
||||
#[cfg(not(windows))]
|
||||
guard: pprof::ProfilerGuard<'static>,
|
||||
}
|
||||
|
||||
@ -9,6 +10,7 @@ impl Profiler {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
#[cfg(feature = "pprof")]
|
||||
#[cfg(not(windows))]
|
||||
guard: pprof::ProfilerGuard::new(100)
|
||||
.expect("profiler launch error"),
|
||||
}
|
||||
@ -16,6 +18,7 @@ impl Profiler {
|
||||
|
||||
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");
|
||||
|
Loading…
Reference in New Issue
Block a user