Skip to content

Commit

Permalink
minor fixes after first local tests - it's up to twice as fast!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 2, 2020
1 parent 9660bbf commit 43c7fd1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gitoxide-core/src/pack/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl FromStr for MemoryMode {
"in-memory-decompressed" => InMemoryDecompressed,
"resolve-bases" => ResolveBases,
"resolve-deltas" => ResolveDeltas,
"resolve-deltas-and-bases" => ResolveBasesAndDeltas,
"resolve-bases-and-deltas" => ResolveBasesAndDeltas,
_ => return Err("invalid value".into()),
})
}
Expand Down
15 changes: 10 additions & 5 deletions src/plumbing/lean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,18 @@ fn prepare(verbose: bool, name: &str) -> ((), Option<progress::Log>) {
feature = "prodash-line-renderer-crossterm",
feature = "prodash-line-renderer-termion"
))]
fn prepare(verbose: bool, name: &str) -> (Option<prodash::line::JoinHandle>, Option<prodash::tree::Item>) {
fn prepare(
verbose: bool,
name: &str,
level_start: u8,
level_end: u8,
) -> (Option<prodash::line::JoinHandle>, Option<prodash::tree::Item>) {
super::init_env_logger(false);

if verbose {
let progress = prodash::Tree::new();
let sub_progress = progress.add_child(name);
let handle = crate::shared::setup_line_renderer(progress, 2, false);
let handle = crate::shared::setup_line_renderer_range(progress, level_start..=level_end, false);
(Some(handle), Some(sub_progress))
} else {
(None, None)
Expand All @@ -208,7 +213,7 @@ pub fn main() -> Result<()> {
pack_path,
directory,
}) => {
let (_handle, progress) = prepare(verbose, "pack-explode");
let (_handle, progress) = prepare(verbose, "pack-explode", 2, 3);
core::pack::index::from_pack(
pack_path,
directory,
Expand All @@ -229,7 +234,7 @@ pub fn main() -> Result<()> {
check,
delete_pack,
}) => {
let (_handle, progress) = prepare(verbose, "pack-explode");
let (_handle, progress) = prepare(verbose, "pack-explode", 2, 2);
core::pack::explode::pack_or_pack_index(
pack_path,
object_path,
Expand All @@ -252,7 +257,7 @@ pub fn main() -> Result<()> {
re_encode,
}) => {
use self::core::pack::verify;
let (_handle, progress) = prepare(verbose, "pack-verify");
let (_handle, progress) = prepare(verbose, "pack-verify", 2, 2);
core::pack::verify::pack_or_pack_index(
path,
progress,
Expand Down
24 changes: 24 additions & 0 deletions src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ pub fn setup_line_renderer(
)
}

#[allow(unused)]
#[cfg(feature = "prodash-line-renderer")]
pub fn setup_line_renderer_range(
progress: prodash::Tree,
levels: std::ops::RangeInclusive<prodash::tree::Level>,
hide_cursor: bool,
) -> prodash::line::JoinHandle {
let output_is_terminal = atty::is(atty::Stream::Stderr);
prodash::line::render(
std::io::stderr(),
progress,
prodash::line::Options {
level_filter: Some(levels),
frames_per_second: DEFAULT_FRAME_RATE,
initial_delay: Some(std::time::Duration::from_millis(1000)),
output_is_terminal,
colored: output_is_terminal && crosstermion::color::allowed(),
timestamp: true,
hide_cursor,
..prodash::line::Options::default()
},
)
}

#[cfg(all(feature = "lean-cli", not(feature = "pretty-cli")))]
pub fn from_env<T: argh::TopLevelCommand>() -> T {
static VERSION: &str = concat!(env!("CARGO_PKG_NAME"), " ", env!("CARGO_PKG_VERSION"));
Expand Down
8 changes: 5 additions & 3 deletions tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
* [x] use progress (one for reading bytes, one for objects, solving the long-standing problem on how to visualize this)
* [x] use new show_throughput method everywhere
* **cli index-from-pack**
* [ ] build index from pack
* [ ] from stdin()
* [ ] complete pack with trailer
* [x] build index from pack
* [x] from stdin()
* [x] complete pack with trailer
* [ ] unit tests for bundle index write
* [ ] journey test for command-line capabilities
* [ ] stress test generating an index for the linux kernel pack (uses 64 bit offsets)
* **cli - verify**
* break progress up into bytes decompressed and compressed bytes read
Expand Down

0 comments on commit 43c7fd1

Please sign in to comment.