mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:55:40 +02:00
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.
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
use crate::{
|
||||
dataframe::values::NuSchema,
|
||||
perf,
|
||||
values::{CustomValueSupport, NuLazyFrame},
|
||||
PolarsPlugin,
|
||||
EngineWrapper, PolarsPlugin,
|
||||
};
|
||||
use nu_path::expand_path_with;
|
||||
use nu_utils::perf;
|
||||
|
||||
use super::super::values::NuDataFrame;
|
||||
use nu_plugin::PluginCommand;
|
||||
@ -399,13 +399,10 @@ fn from_jsonl(
|
||||
inner: vec![],
|
||||
})?;
|
||||
|
||||
perf(
|
||||
engine,
|
||||
perf!(
|
||||
"Lazy json lines dataframe open",
|
||||
start_time,
|
||||
file!(),
|
||||
line!(),
|
||||
column!(),
|
||||
engine.use_color()
|
||||
);
|
||||
|
||||
let df = NuLazyFrame::new(false, df);
|
||||
@ -441,13 +438,10 @@ fn from_jsonl(
|
||||
})?
|
||||
.into();
|
||||
|
||||
perf(
|
||||
engine,
|
||||
perf!(
|
||||
"Eager json lines dataframe open",
|
||||
start_time,
|
||||
file!(),
|
||||
line!(),
|
||||
column!(),
|
||||
engine.use_color()
|
||||
);
|
||||
|
||||
df.cache_and_to_value(plugin, engine, call.head)
|
||||
@ -524,14 +518,7 @@ fn from_csv(
|
||||
})?
|
||||
.into();
|
||||
|
||||
perf(
|
||||
engine,
|
||||
"Lazy CSV dataframe open",
|
||||
start_time,
|
||||
file!(),
|
||||
line!(),
|
||||
column!(),
|
||||
);
|
||||
perf!("Lazy CSV dataframe open", start_time, engine.use_color());
|
||||
|
||||
df.cache_and_to_value(plugin, engine, call.head)
|
||||
} else {
|
||||
@ -569,14 +556,7 @@ fn from_csv(
|
||||
inner: vec![],
|
||||
})?;
|
||||
|
||||
perf(
|
||||
engine,
|
||||
"Eager CSV dataframe open",
|
||||
start_time,
|
||||
file!(),
|
||||
line!(),
|
||||
column!(),
|
||||
);
|
||||
perf!("Eager CSV dataframe open", start_time, engine.use_color());
|
||||
|
||||
let df = NuDataFrame::new(false, df);
|
||||
df.cache_and_to_value(plugin, engine, call.head)
|
||||
|
Reference in New Issue
Block a user