History

[pack-gen] better progress

Sebastian Thiel committed 5 years ago

Commit fdee3811 parent 5b89a0e1 file · +6 −2Browse files

Unified · Split

gitoxide-core/src/pack/create.rs+6−2
@@ -3,6 +3,7 @@ use git_features::progress::Progress; · 2 unmodified lines
3use git_hash::ObjectId;3use git_hash::ObjectId;
4use git_object::bstr::ByteVec;4use git_object::bstr::ByteVec;
5use git_odb::{linked, pack, FindExt};5use git_odb::{linked, pack, FindExt};
6use std::time::Instant;
6use std::{ffi::OsStr, io, path::Path, str::FromStr, sync::Arc};7use std::{ffi::OsStr, io, path::Path, str::FromStr, sync::Arc};
7 8
8pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=2;9pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=2;
@@ -94,9 +95,10 @@ pub fn create( · 85 unmodified lines
94 95
95 let chunk_size = 200;96 let chunk_size = 200;
96 progress.init(Some(3), git_features::progress::steps());97 progress.init(Some(3), git_features::progress::steps());
97 let mut count_progress = progress.add_child("counting");98 let start = Instant::now();
98 count_progress.init(None, git_features::progress::count("objects"));
99 let counts = {99 let counts = {
100 let mut count_progress = progress.add_child("counting");
101 count_progress.init(None, git_features::progress::count("objects"));
100 let counts_iter = pack::data::output::count_objects_iter(102 let counts_iter = pack::data::output::count_objects_iter(
101 Arc::clone(&db),103 Arc::clone(&db),
102 pack::cache::lru::StaticLinkedList::<64>::default,104 pack::cache::lru::StaticLinkedList::<64>::default,
@@ -117,8 +119,10 @@ pub fn create( · 14 unmodified lines
117 count_progress.inc_by(c.len());119 count_progress.inc_by(c.len());
118 counts.extend(c.into_iter());120 counts.extend(c.into_iter());
119 }121 }
122 count_progress.show_throughput(start);
120 counts123 counts
121 };124 };
125
122 progress.inc();126 progress.inc();
123 let num_objects = counts.len();127 let num_objects = counts.len();
124 let entries = pack::data::output::objects_to_entries_iter(128 let entries = pack::data::output::objects_to_entries_iter(