A minimal multithreaded (fastest?) du -sh written in C++20
These are all tested on my 22 core x86 laptop
hyperfine --warmup 3 -i 'idu' 'diskus' 'du -sh' 'gdu -s -c -p' 'dust -d0 -b -n0 -c -P' 'pdu -d1 --no-sort'| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
idu |
66.1 ± 2.6 | 60.7 | 73.0 | 1.00 |
diskus |
148.5 ± 6.9 | 138.8 | 159.7 | 2.25 ± 0.14 |
du -sh |
533.5 ± 23.6 | 505.9 | 571.1 | 8.07 ± 0.48 |
gdu -s -c -p |
192.4 ± 11.6 | 173.0 | 209.4 | 2.91 ± 0.21 |
dust -d0 -b -n0 -c -P |
246.1 ± 17.6 | 224.1 | 270.5 | 3.72 ± 0.30 |
pdu -d1 --no-sort |
76.5 ± 3.0 | 68.9 | 82.0 | 1.16 ± 0.06 |
hyperfine --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' \
'idu' 'diskus' 'du -sh' 'gdu -s -c -p' 'dust -d0 -b -n0 -c -P' 'pdu -d1 --no-sort'| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
idu |
293.1 ± 7.7 | 280.5 | 302.3 | 1.00 |
diskus |
308.9 ± 8.1 | 290.1 | 320.4 | 1.05 ± 0.04 |
du -sh |
1722.9 ± 110.5 | 1573.0 | 1940.4 | 5.88 ± 0.41 |
gdu -s -c -p |
381.8 ± 8.6 | 364.5 | 389.7 | 1.30 ± 0.05 |
dust -d0 -b -n0 -c -P |
395.1 ± 11.2 | 383.8 | 417.7 | 1.35 ± 0.05 |
pdu -d1 --no-sort |
300.8 ± 12.4 | 275.6 | 315.4 | 1.03 ± 0.05 |
Usage:
idu [OPTION...] [PATHS...]
-i, --ignore-errors Do not display file-system errors
-f, --format <FORMAT> Set the display format [possible values:
metric, binary, bytes, kb, kib, mb, mib, gb,
gib, tb, tib] (default: binary)
-j, --threads <NUM> Set the number of threads (0 means total
logical processors) (default: 0)
-c, --count-items Display total count of files and
sub-directories
-d, --dir-greater-than <NUM><UNIT>
List directories >= a specified size
(shallow)
-l, --file-larger-than <NUM><UNIT>
List files >= a specified size
--paths <PATHS> The path(s) to query
-h, --help Print usageidu"/home/mkp/"
62.07 GiBidu -c index.html dev/ Documents/"/home/mkp/index.html"
4.00 KiB
Total sub-directories: 0
Total files: 1
"/home/mkp/dev/"
5.94 GiB
Total sub-directories: 7223
Total files: 106597
"/home/mkp/Documents/"
3.00 MiB
Total sub-directories: 0
Total files: 3idu -f "bytes" -l "300mb" linux/"/home/mkp/dev/linux/"
3.48 GB linux/.git/objects/pack/pack-20b694c5eafaebe6d5d9ef3d4632360563d5dfb3.pack
385.02 MB linux/.git/objects/pack/pack-20b694c5eafaebe6d5d9ef3d4632360563d5dfb3.idx
5849366528 bytes- Linux
- GCC 12+
- CMake 3.20+
- mold linker
curl -fsSL https://raw.githubusercontent.com/MkP369/idu/main/install.sh | bashcmake -B build_release -DCMAKE_BUILD_TYPE=Release
cmake --build build_release -j$(nproc)cmake -B build_debug -DCMAKE_BUILD_TYPE=Debug
cmake --build build_debug -j$(nproc)- batch statx call
- unit tests
- add more display options
- benchmark clang vs gcc?