mirror of
https://github.com/chmln/sd
synced 2024-11-25 04:30:17 +00:00
Freshen up README (#187)
* Switch installation instructions to repology badge * Format benchmark commands
This commit is contained in:
parent
27c217a43e
commit
f2e63dfc56
1 changed files with 21 additions and 73 deletions
94
README.md
94
README.md
|
@ -48,97 +48,45 @@ Some cherry-picked examples, where `sd` shines:
|
|||
|
||||
**Simple replacement on ~1.5 gigabytes of JSON**
|
||||
|
||||
`hyperfine -w 3 'sed -E "s/\"/\'/g" *.json >/dev/null' 'sd "\"" "\'" *.json >/dev/null' --export-markdown out.md`
|
||||
```sh
|
||||
hyperfine --warmup 3 --export-markdown out.md \
|
||||
'sed -E "s/\"/'"'"'/g" *.json > /dev/null' \
|
||||
'sed "s/\"/'"'"'/g" *.json > /dev/null' \
|
||||
'sd "\"" "'"'"'" *.json > /dev/null'
|
||||
```
|
||||
|
||||
| Command | Mean [s] | Min…Max [s] |
|
||||
|:---|---:|---:|
|
||||
| `sed -E "s/\"/'/g" *.json >/dev/null` | 2.338 ± 0.008 | 2.332…2.358 |
|
||||
| `sed "s/\"/'/g" *.json >/dev/null` | 2.365 ± 0.009 | 2.351…2.378 |
|
||||
| `sd "\"" "'" *.json >/dev/null` | **0.997 ± 0.006** | 0.987…1.007 |
|
||||
| `sed -E "s/\"/'/g" *.json > /dev/null` | 2.338 ± 0.008 | 2.332…2.358 |
|
||||
| `sed "s/\"/'/g" *.json > /dev/null` | 2.365 ± 0.009 | 2.351…2.378 |
|
||||
| `sd "\"" "'" *.json > /dev/null` | **0.997 ± 0.006** | 0.987…1.007 |
|
||||
|
||||
Result: ~2.35 times faster
|
||||
|
||||
**Regex replacement on a ~55M json file**:
|
||||
|
||||
```
|
||||
hyperfine \
|
||||
'sed -E "s:(\w+):\1\1:g" dump.json >/dev/null'\
|
||||
"sed 's:\(\w\+\):\1\1:g' dump.json >/dev/null"\
|
||||
'sd "(\w+)" "$1$1" dump.json >/dev/null'
|
||||
```sh
|
||||
hyperfine --warmup 3 --export-markdown out.md \
|
||||
'sed -E "s:(\w+):\1\1:g" dump.json > /dev/null' \
|
||||
'sed "s:\(\w\+\):\1\1:g" dump.json > /dev/null' \
|
||||
'sd "(\w+)" "$1$1" dump.json > /dev/null'
|
||||
```
|
||||
|
||||
| Command | Mean [s] | Min…Max [s] |
|
||||
|:---|---:|---:|
|
||||
| `sed -E "s:(\w+):\1\1:g" dump.json >/dev/null` | 11.315 ± 0.215 | 11.102…11.725 |
|
||||
| `sed 's:\(\w\+\):\1\1:g' dump.json >/dev/null` | 11.239 ± 0.208 | 11.057…11.762 |
|
||||
| `sd "(\w+)" "$1$1" dump.json >/dev/null` | **0.942 ± 0.004** | 0.936…0.951 |
|
||||
| `sed -E "s:(\w+):\1\1:g" dump.json > /dev/null` | 11.315 ± 0.215 | 11.102…11.725 |
|
||||
| `sed "s:\(\w\+\):\1\1:g" dump.json > /dev/null` | 11.239 ± 0.208 | 11.057…11.762 |
|
||||
| `sd "(\w+)" "$1$1" dump.json > /dev/null` | **0.942 ± 0.004** | 0.936…0.951 |
|
||||
|
||||
Result: ~11.93 times faster
|
||||
|
||||
## Installation
|
||||
|
||||
### Cargo
|
||||
Install through
|
||||
[`cargo`](https://doc.rust-lang.org/cargo/getting-started/installation.html) with
|
||||
`cargo install sd`, or through various package managers
|
||||
|
||||
[Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html) is the Rust package manager.
|
||||
|
||||
You can install cargo by
|
||||
```sh
|
||||
curl https://sh.rustup.rs -sSf | sh
|
||||
```
|
||||
|
||||
Then
|
||||
```sh
|
||||
cargo install sd
|
||||
```
|
||||
|
||||
### Alpine Linux
|
||||
|
||||
```sh
|
||||
apk add sd
|
||||
```
|
||||
Before installing, ensure the appropriate [repository](https://pkgs.alpinelinux.org/packages?name=sd) is enabled.
|
||||
|
||||
### Arch Linux
|
||||
|
||||
```sh
|
||||
pacman -S sd
|
||||
```
|
||||
|
||||
### Gentoo (unc3nsored overlay)
|
||||
```
|
||||
emerge -av sys-apps/sd
|
||||
```
|
||||
Before installing, ensure the appropriate [overlay](https://github.com/xxc3nsoredxx/unc3nsored) is enabled.
|
||||
|
||||
### Fedora
|
||||
|
||||
```sh
|
||||
dnf install sd
|
||||
```
|
||||
|
||||
### FreeBSD
|
||||
|
||||
```sh
|
||||
pkg install sd
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
```sh
|
||||
choco install sd-cli
|
||||
```
|
||||
|
||||
### macOS
|
||||
|
||||
```sh
|
||||
brew install sd
|
||||
```
|
||||
|
||||
### Void Linux
|
||||
|
||||
```sh
|
||||
xbps-install sd
|
||||
```
|
||||
[![Packaging status](https://repology.org/badge/vertical-allrepos/sd-find-replace.svg)](https://repology.org/project/sd-find-replace/versions)
|
||||
|
||||
## Quick Guide
|
||||
|
||||
|
|
Loading…
Reference in a new issue