Skip to content

Commit 1f1f581

Browse files
authored
Converted perf function to be a macro. Utilized the perf macro within the polars plugin. (#13224)
In this pull request, I converted the `perf` function within `nu_utils` to a macro. This change facilitates easier usage within plugins by allowing the use of `env_logger` and setting `RUST_LOG=nu_plugin_polars` (or another plugin). Without this conversion, the `RUST_LOG` variable would need to be set to `RUST_LOG=nu_utils::utils`, which is less intuitive and impossible to narrow the perf results to one plugin.
1 parent 0d79b63 commit 1f1f581

File tree

12 files changed

+154
-524
lines changed

12 files changed

+154
-524
lines changed

Cargo.lock

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/nu-cli/src/config_files.rs

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use nu_protocol::{
88
report_error_new, HistoryFileFormat, PipelineData,
99
};
1010
#[cfg(feature = "plugin")]
11-
use nu_utils::utils::perf;
11+
use nu_utils::perf;
1212
use std::path::PathBuf;
1313

1414
#[cfg(feature = "plugin")]
@@ -53,13 +53,10 @@ pub fn read_plugin_file(
5353
// Reading signatures from plugin registry file
5454
// The plugin.msgpackz file stores the parsed signature collected from each registered plugin
5555
add_plugin_file(engine_state, plugin_file.clone(), storage_path);
56-
perf(
56+
perf!(
5757
"add plugin file to engine_state",
5858
start_time,
59-
file!(),
60-
line!(),
61-
column!(),
62-
engine_state.get_config().use_ansi_coloring,
59+
engine_state.get_config().use_ansi_coloring
6360
);
6461

6562
start_time = std::time::Instant::now();
@@ -137,13 +134,10 @@ pub fn read_plugin_file(
137134
}
138135
};
139136

140-
perf(
137+
perf!(
141138
&format!("read plugin file {}", plugin_path.display()),
142139
start_time,
143-
file!(),
144-
line!(),
145-
column!(),
146-
engine_state.get_config().use_ansi_coloring,
140+
engine_state.get_config().use_ansi_coloring
147141
);
148142
start_time = std::time::Instant::now();
149143

@@ -156,13 +150,10 @@ pub fn read_plugin_file(
156150
return;
157151
}
158152

159-
perf(
153+
perf!(
160154
&format!("load plugin file {}", plugin_path.display()),
161155
start_time,
162-
file!(),
163-
line!(),
164-
column!(),
165-
engine_state.get_config().use_ansi_coloring,
156+
engine_state.get_config().use_ansi_coloring
166157
);
167158
}
168159
}
@@ -381,13 +372,10 @@ pub fn migrate_old_plugin_file(engine_state: &EngineState, storage_path: &str) -
381372
);
382373
}
383374

384-
perf(
375+
perf!(
385376
"migrate old plugin file",
386377
start_time,
387-
file!(),
388-
line!(),
389-
column!(),
390-
engine_state.get_config().use_ansi_coloring,
378+
engine_state.get_config().use_ansi_coloring
391379
);
392380
true
393381
}

0 commit comments

Comments
 (0)