Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(mem): add dhat heap profile #622

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading