Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jerluc/sw
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jerluc/sw
- Owner: jerluc
- License: mit
- Created: 2024-08-25T23:04:42.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-26T07:30:06.000Z (5 months ago)
- Last Synced: 2024-08-27T01:29:43.966Z (5 months ago)
- Language: Rust
- Size: 5.86 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `sw` (stopwatch)
`sw` is a simple command-line program inspired by [GNU `time`](https://www.gnu.org/software/time/)
that times the execution of a shell command. Unlike GNU `time` however, `sw` also automatically
records historical timing statistics so you can see things like minimum, maximum, mean, and standard
deviation of historical runs of the same shell command over time.## Installation
To get started, install `sw` from source:
```shell
# Directly from Github
cargo install --git https://github.com/jerluc/sw.git# Or from local source
git clone https://github.com/jerluc/sw.git && cd sw/ && cargo install --path .
```## Usage
To use `sw`, simply use it like the `time` command:
```
sw [COMMAND_ARGS...]
```For example, the first time you run, you'll see the timing for the command:
```shell
sw sleep 1
# Took 1.002365579s
```Then if you run the command again, you'll see the timing along with historical statistics:
```shell
sw sleep 1
# Took 1.001665857s
# Timing statistics for command [sleep 1]
# Total: 2
# Duration (min): 1.001665857s
# Duration (max): 1.002365579s
# Duration (mean): 1.002015718s
# Duration (std dev): 349.861µs
```## Internals
### Historical timings
Historical timings are grouped by command and arguments, and are recorded in a JSON file under the
user's local data directory:- For Linux, this is `$XDG_DATA_HOME/sw/history.json` or `$HOME/.local/share/sw/history.json`
- For macOS, this is `$HOME/Library/Application Support/sw/history.json`
- For Windows, this is `{FOLDERID_LocalAppData}\sw\history.json`This history file is automatically created on first run, so if you want to reset the history, simply
delete the file!## Motivations
I basically had two motivations in creating this software:
1. I often rerun the same command multiple times to execute things like ETL jobs and other data
pipelines. `sw` can be used to track how long these runs take on average compared to the current
run, so that I can quickly identify when something is faster or slower than usual.
2. I wanted an excuse to practice some more Rust :)## Contributing
When contributing to this repository, please follow the steps below:
1. Fork the repository
2. Submit your patch in one commit, or a series of well-defined commits
3. Submit your pull request and make sure you reference the issue you are addressing## License
See [LICENSE](LICENSE)