Crap - A fork of poop
Stop flushing your performance down the drain.
This command line tool uses Linux's perf_event_open and macOS kperf functionality to compare the performance of multiple commands
with a colorful terminal user interface.
Usage: crap [options] <command1> ... <commandN>
Compares the performance of the provided commands.
Options:
-d, --duration <ms> (default: 5000) how long to repeatedly sample each command
--color <when> (default: auto) color output mode
available options: 'auto', 'never', 'ansi'
-s, --shell <shell> (default: none) specify which shell to run commands in
-w, --warmup <count> (default: 0) specify number of warmups before running each command
-f, --allow-failures (default: false) compare performance if a non-zero exit code is returned
| Counters | Linux | macOS | Windows |
|---|---|---|---|
| wall_time | yes | yes | yes |
| peak_rss | yes | yes | yes |
| cpu_cycles | yes | sudo | no |
| instructions | yes | sudo | no |
| cache_references | yes | no | no |
| cache_misses | yes | sudo | no |
| branch_misses | yes | sudo | no |
Tested with Zig 0.15.2.
# set install path to ~/.local to install in ~/.local/bin
zig build -Doptimize=ReleaseSafe -p <install_path>
Crap (so far) is brand new, whereas Hyperfine is a mature project with more configuration options and generally more polish.
However, crap does report peak memory usage as well as 5 other hardware counters, which I personally find useful when doing performance testing. Hey, maybe it will inspire the Hyperfine maintainers to add the extra data points!
By default crap does not run the commands in a shell, use -s/--shell zsh to run the command in a shell.
This has the upside of not including shell spawning noise in the data points collected, and the
downside of not supporting strings inside the commands. Hyperfine by default
runs the commands in a shell, with command line options to disable this.
Crap treats the first command as a reference and the subsequent ones relative to it, giving the user the choice of the meaning of the coloring of the deltas. Hyperfine by default prints the wall-clock-fastest command first, with a command line option to select a different reference command explicitly.
Note: on macos to get some of the extra performance counters, sudo privelage is needed.
- andrewrk: original author of poop, also known for advocating to flush.
- tensorush: made support for macos possible, original pr