summaryrefslogtreecommitdiffstats
path: root/README.md
blob: 20971851c93f60ee5555b3fdd52f3a1233970c4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# diskus

[![Build Status](https://travis-ci.org/sharkdp/diskus.svg?branch=master)](https://travis-ci.org/sharkdp/diskus)

*A minimal, fast alternative to `du -sh`.*

`diskus` is a very simple program that computes the total size of the current directory. It is a
parallelized version of `du -sh`. On my 8-core laptop, it is about nine times faster than `du` for
a cold disk cache and more than twice as fast on a warm disk cache.

``` bash
> diskus
14.56 GB (14556806983 bytes)
```

## Benchmark

The following benchmarks have been performed with [hyperfine](https://github.com/sharkdp/hyperfine) on
a moderately large folder (15GB, 100k directories, 400k files). Smaller folders are not really of any
interest since all programs would finish in a reasonable time that would not interrupt your workflow.

In addition to `du` and `diskus`, we also add [tin-summer](https://github.com/vmchale/tin-summer) (`sn`) and
[`dust`](https://github.com/bootandy/dust) in our comparison. Both are also written in Rust and provide
much more features than `diskus` (check them out!). The optimal number of threads for `sn` (`-j` option) was
determined via `hyperfine --parameter-scan`.

### Cold disk cache

```bash
sudo -v
hyperfine --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' \
    'diskus' 'sn p -d0 -j8' 'du -sb' 'dust -d0'
```
(the `sudo`/`sync`/`drop_caches` commands are a way to
[clear the filesystem caches between benchmarking runs](https://github.com/sharkdp/hyperfine#io-heavy-programs))

| Command | Mean [s] | Min…Max [s] |
|:---|---:|---:|
| `diskus` | 1.729 ± 0.012 | 1.717…1.756 |
| `sn p -d0 -j8` | 9.778 ± 0.098 | 9.587…9.904 |
| `du -sb` | 16.016 ± 0.067 | 15.923…16.147 |
| `dust -d0` | 19.845 ± 0.466 | 19.428…20.948 |

### Warm disk cache

On a warm disk cache, the differences are smaller:
```bash
hyperfine --warmup 5 'diskus' 'sn p -d0 -j8' 'du -sb' 'dust -d0'
```

| Command | Mean [ms] | Min…Max [ms] |
|:---|---:|---:|
| `diskus` | 465.9 ± 14.7 | 446.5…487.4 |
| `sn p -d0 -j8` | 596.4 ± 12.2 | 579.2…615.9 |
| `du -sb` | 1100.3 ± 20.5 | 1086.9…1153.0 |
| `dust -d0` | 3560.1 ± 27.8 | 3521.7…3612.8 |

## Installation

### On Debian-based systems

``` bash
wget "https://github.com/sharkdp/diskus/releases/download/v0.3.1/diskus_0.3.1_amd64.deb"
sudo dpkg -i diskus_0.3.1_amd64.deb
```

### On Arch-based systems

Download from the AUR: [diskus](https://aur.archlinux.org/packages/diskus/) or [diskus-bin](https://aur.archlinux.org/packages/diskus-bin/)

### On other distrubutions

Check out the [release page](https://github.com/sharkdp/diskus/releases) for binary builds.

### Via cargo

If you have Rust 1.29 or higher, you can install `diskus` from source via `cargo`:
```
cargo install diskus
```

## License

Licensed under either of

 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.