Skip to content

Commit

Permalink
fix(cli): Remove __ prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Mar 5, 2024
1 parent caf4c30 commit 6d8708a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/bin/cargo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ fn setup_logger() -> Option<tracing_chrome::FlushGuard> {
.with_filter(env);

let (profile_layer, profile_guard) =
if env_to_bool(std::env::var_os("__CARGO_LOG_PROFILE").as_deref()) {
if env_to_bool(std::env::var_os("CARGO_LOG_PROFILE").as_deref()) {
let capture_args =
env_to_bool(std::env::var_os("__CARGO_LOG_PROFILE_CAPTURE_ARGS").as_deref());
env_to_bool(std::env::var_os("CARGO_LOG_PROFILE_CAPTURE_ARGS").as_deref());
let (layer, guard) = tracing_chrome::ChromeLayerBuilder::new()
.include_args(capture_args)
.build();
Expand Down
8 changes: 5 additions & 3 deletions src/doc/contrib/src/tests/profiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ Cargo leverages [tracing](https://crates.io/crates/tracing)
as a basic, hierarchical built-in profiler.

Environment variables:
- `__CARGO_LOG_PROFILE=<true|1>`: log tracing events to a file in the current working directory
- `__CARGO_LOG_PROFILE_CAPTURE_ARGS=<true|1>`: include arguments in the events
- `CARGO_LOG_PROFILE=<true|1>`: log tracing events to a file in the current working directory
- `CARGO_LOG_PROFILE_CAPTURE_ARGS=<true|1>`: include arguments in the events

At process exit, your trace will be in a file like `trace-1668480819035032.json`.
Open that file with [ui.perfetto.dev](https://ui.perfetto.dev) (or chrome://tracing) to browse your trace.

Example:
```console
$ # Output first three levels of profiling info
$ __CARGO_LOG_PROFILE=true cargo generate-lockfile
$ CARGO_LOG_PROFILE=true cargo generate-lockfile
```

**Note:** This is intended for the development of cargo and there are no compatibility guarantees on this functionality.

## Benchmarking

### Benchsuite
Expand Down

0 comments on commit 6d8708a

Please sign in to comment.