-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench.sh
executable file
·73 lines (62 loc) · 2.38 KB
/
bench.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
73
#!/bin/bash
# parameters
files=1000
warm=10
# cleanup
cleanup() {
echo "cleaning up"
rm -rf /tmp/bench
}
trap cleanup EXIT
# check if hyperfine is installed
if ! command -v hyperfine &>/dev/null; then
echo "hyperfine is not installed. Please install hyperfine to continue."
exit 1
fi
# check if hugo is installed
if ! command -v hugo &>/dev/null; then
echo "hugo is not installed. Please install hugo to continue."
fi
# cloning candidates
echo "clone SSGs"
git clone https://github.com/acmpesuecc/anna /tmp/bench/anna
git clone https://github.com/anirudhRowjee/saaru /tmp/bench/saaru
git clone https://github.com/NavinShrinivas/sapling /tmp/bench/sapling
# copy benchmark file
cp /tmp/bench/anna/site/content/posts/bench.md /tmp/bench/test.md
# build saaru & anna
echo "build SSGs"
cd /tmp/bench/anna && go build && cd ..
cd saaru && cargo build --release && mv ./target/release/saaru . && cd ..
cd sapling && cargo build --release && mv ./target/release/sapling . && cd ..
## setup hugo
hugo new site /tmp/bench/hugo; cd /tmp/bench/hugo
hugo new theme mytheme; echo "theme = 'mytheme'" >> hugo.toml; cd /tmp/bench
## setup 11ty
mkdir /tmp/bench/11ty -p
# clean content/* dirs
echo "Cleaning content directories"
rm -rf /tmp/bench/anna/site/content/posts/*
rm -rf /tmp/bench/saaru/docs/src/*
rm -rf /tmp/bench/sapling/benchmark/content/blog/*
rm -rf /tmp/bench/hugo/content/*
rm -rf /tmp/bench/11ty/*
# create multiple copies of the test file
echo "Spawning $files different markdown files..."
for ((i = 0; i < files; i++)); do
cp /tmp/bench/test.md "/tmp/bench/anna/site/content/posts/test_$i.md"
cp /tmp/bench/test.md "/tmp/bench/saaru/docs/src/test_$i.md"
cp /tmp/bench/test.md "/tmp/bench/sapling/benchmark/content/blogs/test_$i.md"
cp /tmp/bench/test.md "/tmp/bench/hugo/content/test_$i.md"
cp /tmp/bench/test.md "/tmp/bench/11ty/test_$i.md"
done
# run hyperfine
echo -e "\n"
echo "running benchmark: $files md files and $warm warmup runs"
echo -e "\n"
# cd /tmp/bench/11ty && hyperfine -p 'sync' -w $warm "npx @11ty/eleventy" && cd ..
# cd /tmp/bench/hugo && hyperfine -p 'sync' -w $warm "hugo" && cd .
cd /tmp/bench/saaru && hyperfine -p 'sync' -w $warm "./saaru --base-path ./docs" && cd ..
cd /tmp/bench/sapling/benchmark && hyperfine -p 'sync' -w $warm "../sapling run" && cd .. && cd ..
cd /tmp/bench/anna && hyperfine -p 'sync' -w $warm "./anna" && cd ..
echo -e "\n"