forked from luispedro/fna2faa
-
Notifications
You must be signed in to change notification settings - Fork 2
/
benchmark.sh
executable file
·72 lines (58 loc) · 2.43 KB
/
benchmark.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
command -v awk >/dev/null 2>&1 || {
echo "'awk' not found. Aborting benchmark." >&2
exit 1; }
command -v getopt >/dev/null 2>&1 || {
echo "'getopt' not found. Aborting benchmark." >&2
exit 1; }
command -v git >/dev/null 2>&1 || {
echo "'git' not found. Aborting benchmark." >&2
exit 1; }
command -v hyperfine >/dev/null 2>&1 || {
echo "'hyperfine' not found. Aborting benchmark." >&2
exit 1; }
CMD="fna2faa"
# Parse args using getopt (instead of getopts) to allow arguments before options
ARGS=$(getopt -o s -l static -n "$0" -- "$@")
# reorganize arguments as returned by getopt
eval set -- "$ARGS"
while true; do
case "$1" in
# Shift before to throw away option
# Shift after if option has a required positional argument
-s|--static)
shift
CMD="fna2faa-static"
;;
--)
shift
break
;;
esac
done
if [ "$#" -ne 1 ]; then
echo "Please specify the commit with which to benchmark against"
exit 1
fi
if [[ -n $(git status --porcelain) ]]; then
echo "!! Warning this script will benchmark the most recent commit against the provided commit. Please commit your changes !!"
exit 1;
fi
COMMIT_PREV="$(git rev-parse --short "$1")"
COMMIT_CURR="$(git rev-parse --short HEAD)"
git worktree remove -f "fna2faa-$COMMIT_PREV-folder"
rm -rf fna2faa "fna2faa-$COMMIT_PREV" "fna2faa-$COMMIT_CURR"
( git worktree add fna2faa-prev-folder "$1" && cd fna2faa-prev-folder && make $CMD && mv fna2faa ../fna2faa-previous && cd .. && git worktree remove -f fna2faa-prev-folder )
make $CMD && mv $CMD fna2faa-current
echo ">> Benchmarking (8 long sequences - 343M nucleotides) <<"
hyperfine \
-n "Current commit $COMMIT_CURR" \
"awk '{if ($$0 !~ /^>/) {for (i=0; i<1000000; i++) print} else {print}}' tests/test.fa | ./fna2faa-current --quiet - 1>/dev/null" \
-n "Previous commit $COMMIT_PREV" \
"awk '{if ($$0 !~ /^>/) {for (i=0; i<1000000; i++) print} else {print}}' tests/test.fa | ./fna2faa-previous --quiet - 1>/dev/null"
echo ">> Benchmarking (8M short sequences - 343M nucleotides) <<"
hyperfine \
-n "Current commit $COMMIT_CURR" \
"awk '{a[NR]=$$0}END{for (i=0; i<1000000; i++){for(k in a){print a[k]}}}' tests/test.fa | ./fna2faa-current --quiet - 1>/dev/null" \
-n "Previous commit $COMMIT_PREV" \
"awk '{a[NR]=$$0}END{for (i=0; i<1000000; i++){for(k in a){print a[k]}}}' tests/test.fa | ./fna2faa-previous --quiet - 1>/dev/null"