mirror of
https://github.com/bootandy/dust.git
synced 2026-03-12 21:22:51 -07:00
Large refactor. Use rayon, 10X performance boost
Code changes: Removed ignore & channel crates. Using a single reciever thread to build a hashmap to prevend duplicate inodes being reported gave a severe performance penalty Using rayon crate with some hand crafted file traversal has improved performance aprox 10X Behaviour changes: Removed parameter 'limit by filesystem' - don't think this is used, and I only added it as it was easy to add with the ignore crate. Sym links will now not appear in the output tree unless using '-s' 'apparent-size' flag Change behaviour of multiple args so that it unifies them and compares them under one tree instead of treating them individually: https://github.com/bootandy/dust/issues/136
This commit is contained in:
@@ -114,8 +114,6 @@ pub fn test_main_long_paths() {
|
||||
.unwrap()
|
||||
.stdout;
|
||||
let output = str::from_utf8(&assert).unwrap();
|
||||
println!("{:?}", output.trim());
|
||||
println!("{:?}", main_output_long_paths().trim());
|
||||
assert!(output.contains(&main_output_long_paths()));
|
||||
}
|
||||
|
||||
@@ -204,9 +202,9 @@ fn no_substring_of_names_output() -> String {
|
||||
0B ┌── long_dir_name_what_a_very_long_dir_name_what_happens_when_this_g..
|
||||
4.0K ├── dir_name_clash
|
||||
4.0K │ ┌── hello
|
||||
8.0K ├─┴ dir_substring
|
||||
4.0K │ ┌── hello
|
||||
8.0K ├─┴ dir
|
||||
4.0K │ ┌── hello
|
||||
8.0K ├─┴ dir_substring
|
||||
24K ┌─┴ test_dir2
|
||||
"
|
||||
.trim()
|
||||
@@ -218,10 +216,10 @@ fn no_substring_of_names_output() -> String {
|
||||
"
|
||||
0B ┌── long_dir_name_what_a_very_long_dir_name_what_happens_when_this_g..
|
||||
4.0K │ ┌── hello
|
||||
4.0K ├─┴ dir_substring
|
||||
4.0K ├─┴ dir
|
||||
4.0K ├── dir_name_clash
|
||||
4.0K │ ┌── hello
|
||||
4.0K ├─┴ dir
|
||||
4.0K ├─┴ dir_substring
|
||||
12K ┌─┴ test_dir2
|
||||
"
|
||||
.trim()
|
||||
@@ -247,8 +245,8 @@ pub fn test_unicode_directories() {
|
||||
fn unicode_dir() -> String {
|
||||
// The way unicode & asian characters are rendered on the terminal should make this line up
|
||||
"
|
||||
0B ┌── 👩.unicode │ █ │ 0%
|
||||
0B ├── ラウトは難しいです!.japan│ █ │ 0%
|
||||
0B ┌── ラウトは難しいです!.japan│ █ │ 0%
|
||||
0B ├── 👩.unicode │ █ │ 0%
|
||||
4.0K ┌─┴ test_dir_unicode │██████████████████████████████████ │ 100%
|
||||
"
|
||||
.trim()
|
||||
@@ -258,8 +256,8 @@ fn unicode_dir() -> String {
|
||||
#[cfg(target_os = "macos")]
|
||||
fn unicode_dir() -> String {
|
||||
"
|
||||
0B ┌── 👩.unicode │ █ │ 0%
|
||||
0B ├── ラウトは難しいです!.japan│ █ │ 0%
|
||||
0B ┌── ラウトは難しいです!.japan│ █ │ 0%
|
||||
0B ├── 👩.unicode │ █ │ 0%
|
||||
0B ┌─┴ test_dir_unicode │ █ │ 0%
|
||||
"
|
||||
.trim()
|
||||
|
||||
@@ -142,8 +142,8 @@ pub fn test_number_of_files() {
|
||||
.unwrap()
|
||||
.stdout;
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
assert!(output.contains("1 ┌── hello_file"));
|
||||
assert!(output.contains("1 ├── a_file "));
|
||||
assert!(output.contains("1 ┌── a_file "));
|
||||
assert!(output.contains("1 ├── hello_file"));
|
||||
assert!(output.contains("3 ┌─┴ many"));
|
||||
assert!(output.contains("4 ┌─┴ test_dir"));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ use assert_cmd::Command;
|
||||
use std::cmp::max;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::panic;
|
||||
use std::path::PathBuf;
|
||||
use std::str;
|
||||
|
||||
@@ -61,12 +60,12 @@ pub fn test_soft_sym_link() {
|
||||
.output();
|
||||
assert!(c.is_ok());
|
||||
|
||||
let c = format!(" ┌── {}", get_file_name(link_name_s.into()));
|
||||
let b = format!(" ├── {}", get_file_name(file_path_s.into()));
|
||||
let c = format!(" ├── {}", get_file_name(link_name_s.into()));
|
||||
let b = format!(" ┌── {}", get_file_name(file_path_s.into()));
|
||||
let a = format!("─┴ {}", dir_s);
|
||||
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd.arg("-p").arg("-c").arg(dir_s).unwrap().stdout;
|
||||
let output = cmd.arg("-p").arg("-c").arg("-s").arg(dir_s).unwrap().stdout;
|
||||
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
|
||||
@@ -125,9 +124,16 @@ pub fn test_recursive_sym_link() {
|
||||
let b = format!(" └── {}", get_file_name(link_name_s.into()));
|
||||
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd.arg("-p").arg("-c").arg("-r").arg(dir_s).unwrap().stdout;
|
||||
|
||||
let output = cmd
|
||||
.arg("-p")
|
||||
.arg("-c")
|
||||
.arg("-r")
|
||||
.arg("-s")
|
||||
.arg(dir_s)
|
||||
.unwrap()
|
||||
.stdout;
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
|
||||
assert!(output.contains(a.as_str()));
|
||||
assert!(output.contains(b.as_str()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user