-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
379 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
target | ||
tarpaulin-report.html | ||
cobertura.xml | ||
svejk.txt | ||
rur.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -eu | ||
|
||
echo "# Benchmarks" | ||
echo | ||
echo 'This page contains `rew` benchmarks against various other tools:' | ||
echo | ||
echo "- [GNU coreutils](https://www.gnu.org/software/coreutils/)" | ||
echo "- [uutils coreutils](https://github.com/uutils/coreutils?tab=readme-ov-file)" | ||
|
||
specs() { | ||
echo "<details>" | ||
echo "<summary><code>$1</code></summary>" | ||
echo | ||
echo '```' | ||
sh -c "$1" | ||
echo '```' | ||
echo | ||
echo "</details>" | ||
} | ||
|
||
echo | ||
echo "## Environment" | ||
echo | ||
echo "All benchmarks were run within the following environment." | ||
echo | ||
echo "System:" | ||
echo | ||
specs 'uname -a' | ||
specs 'lscpu' | ||
specs 'lsmem' | ||
echo | ||
echo "Software:" | ||
echo | ||
specs 'hyperfine --version' | ||
specs 'rew --version' | ||
specs 'coreutils --help | head -n1' | ||
specs 'seq --version' | ||
specs 'head --version' | ||
|
||
BASE_DATA_URL=https://jpikl.github.io/data | ||
|
||
SVEJK_FILE=svejk.txt | ||
SVEJK_REPEAT=100 | ||
SVEJK_INIT="curl $BASE_DATA_URL/$SVEJK_FILE | rew loop $SVEJK_REPEAT >$SVEJK_FILE" | ||
|
||
RUR_FILE=rur.txt | ||
RUR_REPEAT=1000 | ||
RUR_INIT="curl $BASE_DATA_URL/$RUR_FILE | rew loop $RUR_REPEAT >$RUR_FILE" | ||
|
||
[ -f "$SVEJK_FILE" ] || sh -c "$SVEJK_INIT" | ||
[ -f "$RUR_FILE" ] || sh -c "$RUR_INIT" | ||
|
||
echo | ||
echo "## Data" | ||
echo | ||
echo "The following text files were used as input data for benchmarking." | ||
echo | ||
echo '```shell' | ||
echo "$SVEJK_INIT" | ||
echo '```' | ||
echo | ||
echo "- UTF-8, non-ascii (czech diacritics)" | ||
echo "- 5913 lines (repeated $SVEJK_REPEAT times)" | ||
echo "- very long lines (up to 4952 chars)" | ||
echo "- trimmed whitespaces" | ||
echo | ||
echo '```shell' | ||
echo "$RUR_INIT" | ||
echo '```' | ||
echo | ||
echo "- UTF-8, non-ascii (czech diacritics)" | ||
echo "- 4477 lines (repeated $RUR_REPEAT times)" | ||
echo "- short lines (up to 81 chars)" | ||
echo "- untrimmed whitespaces" | ||
|
||
BENCH_OUT=.bench.md | ||
|
||
bench_group() { | ||
echo | ||
echo "### $1" | ||
} | ||
|
||
bench() { | ||
set -- hyperfine --warmup 5 "$@" | ||
"$@" --sort mean-time --export-markdown "$BENCH_OUT" 1>&2 | ||
|
||
echo | ||
echo "Command:" | ||
echo | ||
echo '```shell' | ||
|
||
printf "$1" | ||
shift | ||
|
||
while [ $# -gt 0 ]; do | ||
printf ' \\\n ' | ||
|
||
case "$1" in | ||
--warmup) | ||
printf "%s %s" "$1" "$2" | ||
shift 2 | ||
;; | ||
--setup | --cleanup) | ||
printf "%s '%s'" "$1" "$2" | ||
shift 2 | ||
;; | ||
*) | ||
printf "'%s'" "$1" | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
echo | ||
echo '```' | ||
echo | ||
echo "Results:" | ||
echo | ||
|
||
cat "$BENCH_OUT" | ||
rm "$BENCH_OUT" | ||
} | ||
|
||
echo | ||
echo "## Runs" | ||
|
||
bench_group "rew seq" | ||
for MULT in '' 0 00; do | ||
bench \ | ||
"seq 1 1$MULT 1000000$MULT" \ | ||
"rew seq 1..1000000$MULT 1$MULT" | ||
done | ||
exit | ||
bench_group "rew first" | ||
for FILE in "$SVEJK_FILE" "$RUR_FILE"; do | ||
bench \ | ||
"head -n 100000 <$FILE" \ | ||
"coreutils head -n 100000 <$FILE" \ | ||
"rew first 100000 <$FILE" | ||
done | ||
|
||
bench_group "rew last" | ||
for FILE in "$SVEJK_FILE" "$RUR_FILE"; do | ||
bench \ | ||
"tail -n 100000 <$FILE" \ | ||
"coreutils tail -n 100000 <$FILE" \ | ||
"rew last 100000 <$FILE" | ||
done | ||
|
||
bench_group "rew cat" | ||
for FILE in "$SVEJK_FILE" "$RUR_FILE"; do | ||
bench \ | ||
"cat <$FILE" \ | ||
"coreutils cat <$FILE" \ | ||
"rew cat <$FILE" \ | ||
"rew cat --bytes <$FILE" \ | ||
"rew cat --chars <$FILE" \ | ||
"rew cat --lines <$FILE" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.