Add env shorthand

This commit is contained in:
JT
2021-11-04 15:32:35 +13:00
parent ea27300ca0
commit 1949ba080e
8 changed files with 384 additions and 32 deletions

View File

@ -3,7 +3,7 @@ use std::time::Instant;
use nu_engine::eval_block;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape};
use nu_protocol::{IntoPipelineData, PipelineData, Signature, SyntaxShape, Value};
#[derive(Clone)]
pub struct Benchmark;
@ -42,7 +42,12 @@ impl Command for Benchmark {
eval_block(engine_state, &mut stack, block, PipelineData::new())?.into_value();
let end_time = Instant::now();
println!("{} ms", (end_time - start_time).as_millis());
Ok(PipelineData::new())
let output = Value::Duration {
val: (end_time - start_time).as_nanos() as i64,
span: call.head,
};
Ok(output.into_pipeline_data())
}
}