Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mustakimali/dux
Calculate disk space used by a folder - A rust experiment
https://github.com/mustakimali/dux
Last synced: about 2 months ago
JSON representation
Calculate disk space used by a folder - A rust experiment
- Host: GitHub
- URL: https://github.com/mustakimali/dux
- Owner: mustakimali
- Created: 2021-10-09T17:02:28.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-23T20:56:04.000Z (2 months ago)
- Last Synced: 2024-10-24T03:37:48.402Z (2 months ago)
- Language: Rust
- Homepage: https://mustak.im/playing-with-rust-writing-gnu-du/
- Size: 39.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dux
A Rust implementation of GNU coreutils `du` in order to learn and explore Rust. This is by no means better, faster or smarter compared to `du`. So don't use it.## Build
```bash
# build
$ cargo build --release# build and publish to ~/bin/ folder
$ ./publish
```## Usage
```bash
# current path
$ dux
Total size is 204828703 bytes (204.83 MB) across 1176 items# specify a path
$ dux ~/bin/
Total size is 586934311 bytes (586.93 MB) across 3372 items# list largest files
$ dux -l
Largest files:
+----------+----------------+
| Size | File |
+----------+----------------+
| 23.56 MB | {file 1} |
+----------+----------------+Total size is 586934311 bytes (586.93 MB) across 3372 items
```### Cli Args
```
dux 0.2.0Calculate disk space used by a folder
USAGE:
dux [OPTIONS] [PATH]ARGS:
The folder to use (default to current directory)OPTIONS:
-h, --help Print help information
-l, --list-large-files Lists top 10 largest files
-V, --version Print version information
```## Performance
For smaller directory, the performance is on-par or better than `du` (I have no idea why!)```bash
$ time du -hd 0
126G .
du -hd 0 0.01s user 0.04s system 47% cpu 0.088 total$ time dux
Total size is 129930609382 bytes (129.93 GB) across 159 items
dux 0.00s user 0.01s system 51% cpu 0.024 total
```but for larger folder `du` is `3x` faster at least,
```bash
$ time du -hd 0
699M .
du -hd 0 0.05s user 0.67s system 48% cpu 1.498 total$ time dux
Total size is 666559986 bytes (666.56 MB) across 31623 items
dux 0.21s user 3.16s system 76% cpu 4.390 total```
## Suggestions
If you have any idea about how the performance can be improved (without writing unsafe code) and anything to make the code more idiomatic - then help this friend out by sending PR.