Last active
March 4, 2024 15:33
-
-
Save MaxGyver83/75a7946318285514612144a46c06972d to your computer and use it in GitHub Desktop.
Test script used to measure the performance of emailbook, emailbook-janet and aercbook
This file contains hidden or 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
#!/bin/sh | |
usage() { | |
echo "Usage: | |
$0 1 janet onecall | |
$0 100 sh manycalls | |
" | |
} | |
case "$1" in | |
""|-h|--help) usage; exit;; | |
esac | |
count=${1:-1} | |
impl=${2:-janet} | |
method=${3:-onecall} | |
mailfolder=/media/ubuntu/home/max/mail/web.de/INBOX/cur | |
EMAILBOOK_JANET=~/repos/emailbook-janet/emailbook.janet | |
EMAILBOOK_JANET_BIN=~/repos/emailbook-janet/build/emailbook-janet | |
EMAILBOOK_SH=~/repos/emailbook/emailbook | |
AERCBOOK=~/repos/aercbook/zig-out/bin/aercbook | |
BOOK_JANET=/tmp/emailbook-janet.txt | |
BOOK_JANET_BIN=/tmp/emailbook-janet-bin.txt | |
BOOK_SH=/tmp/emailbook-sh.txt | |
BOOK_AERCBOOK=/tmp/aercbook.txt | |
ALL_ARG='--all' | |
parse_test_one_call() { | |
if [ $impl = janet ] || [ $impl = janet-bin ]; then | |
cd "$mailfolder" | |
ls -1 | head -n $count | $tool $book --parse-files $ALL_ARG | |
else | |
for file in $(ls -1 "$mailfolder" | head -n $count); do | |
# printf "\n$mailfolder/$file\n" | |
sed '/^$/Q' "$mailfolder/$file" | |
done | $tool $book --parse $ALL_ARG | |
fi | |
} | |
parse_test_many_calls() { | |
for file in $(ls -1 "$mailfolder" | head -n $count); do | |
# printf "\n$mailfolder/$file\n" | |
cat "$mailfolder/$file" | $tool $book --parse $ALL_ARG | |
done | |
} | |
if [ $impl = janet ]; then | |
tool=$EMAILBOOK_JANET | |
book=$BOOK_JANET | |
elif [ $impl = janet-bin ]; then | |
tool=$EMAILBOOK_JANET_BIN | |
book=$BOOK_JANET_BIN | |
elif [ $impl = aercbook ]; then | |
tool=$AERCBOOK | |
book=$BOOK_AERCBOOK | |
ALL_ARG='--add-all' | |
else | |
tool=$EMAILBOOK_SH | |
book=$BOOK_SH | |
fi | |
rm $book 2> /dev/null | |
if [ $method = onecall ]; then | |
time parse_test_one_call | |
else | |
time parse_test_many_calls | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment