forked from mirrors/jj
working_copy: simply collect() proto file states into BTreeMap
Suppose the input list is presorted, sorting a sorted vec would be cheaper than .insert()-ing sorted items one by one. In my "linux" repo (watchman eanbled): - jj-0: baseline - jj-1: previous (don't randomize by HashMap) - jj-2: this % hyperfine --sort command --warmup 3 --runs 10 -L bin jj-0,jj-1,jj-2 \ "target/release-with-debug/{bin} -R ~/mirrors/linux status" Benchmark 1: target/release-with-debug/jj-0 -R ~/mirrors/linux status Time (mean ± σ): 1.034 s ± 0.020 s [User: 0.881 s, System: 0.212 s] Range (min … max): 1.011 s … 1.068 s 10 runs Benchmark 2: target/release-with-debug/jj-1 -R ~/mirrors/linux status Time (mean ± σ): 849.3 ms ± 13.8 ms [User: 710.7 ms, System: 199.3 ms] Range (min … max): 821.7 ms … 870.2 ms 10 runs Benchmark 3: target/release-with-debug/jj-2 -R ~/mirrors/linux status Time (mean ± σ): 786.2 ms ± 16.7 ms [User: 650.7 ms, System: 204.1 ms] Range (min … max): 760.8 ms … 805.2 ms 10 runs Relative speed comparison 1.32 ± 0.04 target/release-with-debug/jj-0 -R ~/mirrors/linux status 1.08 ± 0.03 target/release-with-debug/jj-1 -R ~/mirrors/linux status 1.00 target/release-with-debug/jj-2 -R ~/mirrors/linux status
This commit is contained in:
parent
ee6a1e2c0a
commit
5186066cf5
1 changed files with 7 additions and 6 deletions
|
@ -197,12 +197,13 @@ fn file_state_to_proto(file_state: &FileState) -> crate::protos::working_copy::F
|
|||
fn file_states_from_proto(
|
||||
proto: &[crate::protos::working_copy::FileStateEntry],
|
||||
) -> BTreeMap<RepoPath, FileState> {
|
||||
let mut file_states = BTreeMap::new();
|
||||
for entry in proto {
|
||||
let path = RepoPath::from_internal_string(&entry.path);
|
||||
file_states.insert(path, file_state_from_proto(entry.state.as_ref().unwrap()));
|
||||
}
|
||||
file_states
|
||||
proto
|
||||
.iter()
|
||||
.map(|entry| {
|
||||
let path = RepoPath::from_internal_string(&entry.path);
|
||||
(path, file_state_from_proto(entry.state.as_ref().unwrap()))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn sparse_patterns_from_proto(
|
||||
|
|
Loading…
Reference in a new issue