From 35359cbc22234a247ca4e96db8509e9469512d09 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 26 Jan 2020 09:09:51 +1300 Subject: [PATCH] Buffer tables until a timeout or threshold is met (#1283) --- src/commands/table.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/commands/table.rs b/src/commands/table.rs index 6f75b63747..1de2665a77 100644 --- a/src/commands/table.rs +++ b/src/commands/table.rs @@ -3,8 +3,10 @@ use crate::format::TableView; use crate::prelude::*; use nu_errors::ShellError; use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; +use std::time::Instant; -const STREAM_PAGE_SIZE: usize = 100; +const STREAM_PAGE_SIZE: usize = 1000; +const STREAM_TIMEOUT_CHECK_INTERVAL: usize = 100; pub struct Table; @@ -59,7 +61,8 @@ fn table(args: CommandArgs, registry: &CommandRegistry) -> Result = VecDeque::new(); - for _ in 0..STREAM_PAGE_SIZE { + let start_time = Instant::now(); + for idx in 0..STREAM_PAGE_SIZE { if let Some(val) = delay_slot { new_input.push_back(val); delay_slot = None; @@ -89,6 +92,15 @@ fn table(args: CommandArgs, registry: &CommandRegistry) -> Result= 1 { + break; + } + } } }