Skip to content

Commit

Permalink
add dhat heap profile (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibigbug authored Oct 14, 2024
1 parent b745dd9 commit fd93efa
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ opt-level = "s"
codegen-units = 1
lto = true
strip = true
debug = 1

[patch.crates-io]
tokio-rustls = { git = "https://github.com/Watfaq/tokio-rustls.git", rev = "6b9af8ac7bb5abc159d9a67e9ddbf84127559a4a"}
Expand Down
6 changes: 5 additions & 1 deletion clash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ tracing = ["clash_lib/tracing"]
bench = ["clash_lib/bench"]
onion = ["clash_lib/onion"]

dhat-heap = ["dep:dhat"]

[dependencies]
clap = { version = "4.5.19", features = ["derive"] }

clash_lib = { path = "../clash_lib", version = "*", default-features = false }
clash_lib = { path = "../clash_lib", version = "*", default-features = false }

dhat = { version = "0.3.3", optional = true }
8 changes: 8 additions & 0 deletions clash/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#[cfg(feature = "dhat-heap")]
#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc;

extern crate clash_lib as clash;

use clap::Parser;
Expand Down Expand Up @@ -45,6 +49,9 @@ struct Cli {
}

fn main() {
#[cfg(feature = "dhat-heap")]
let _profiler = dhat::Profiler::new_heap();

let cli = Cli::parse();

if cli.version {
Expand Down Expand Up @@ -81,6 +88,7 @@ fn main() {
}
}
}

match clash::start(clash::Options {
config: clash::Config::File(file),
cwd: cli.directory.map(|x| x.to_string_lossy().to_string()),
Expand Down

0 comments on commit fd93efa

Please sign in to comment.