Skip to content

Commit

Permalink
meta/gh: add hugo and 11ty to bench
Browse files Browse the repository at this point in the history
  • Loading branch information
polarhive committed Apr 11, 2024
1 parent e159c6a commit e4aae40
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 22 deletions.
38 changes: 36 additions & 2 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Benchmark

on:
workflow_dispatch:
push:
tags:
- '*'

jobs:
benchmark:
Expand All @@ -17,11 +20,42 @@ jobs:
sudo apt-get update
sudo apt-get install -y hyperfine
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: 'latest'

- name: Setup Node
uses: actions/[email protected]
with:
node-version: 'latest'

- name: Cache npm
uses: actions/[email protected]
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}

- name: Cache Eleventy .cache
uses: actions/[email protected]
with:
path: ./.cache
key: ${{ runner.os }}-eleventy-fetch-cache

- run: npm install @11ty/eleventy

- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"


- name: Cache Cargo dependencies
uses: actions/[email protected]
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Install Rust
uses: actions-rs/[email protected]
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ defaults:
jobs:
build:
runs-on: ubuntu-latest
needs: test-and-coverage
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
Expand All @@ -32,7 +31,7 @@ jobs:
- uses: actions/checkout@v4

- name: setup go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0

- name: setup go
uses: actions/setup-go@v4
uses: actions/setup-go@v5

- name: run goreleaser
uses: goreleaser/goreleaser-action@v5
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Go Test and Coverage
name: Tests

on:
push:
pull_request:
workflow_dispatch:

defaults:
Expand All @@ -16,7 +15,7 @@ jobs:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

Expand Down
37 changes: 23 additions & 14 deletions test/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,53 @@ if ! command -v hyperfine &>/dev/null; then
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
sleep 1

# copy benchmark file
cp /tmp/bench/anna/site/content/posts/bench.md /tmp/bench/test.md

# checkout specific versions
cd /tmp/bench/anna && git checkout v1.0.0-alpha && cd ..
cd saaru && git checkout c17930724fcaad67e1cfa3cc969667d043c1b826 && cd ..
sleep 1

# build SSGs
# build saaru & anna
echo "build SSGs"
cd /tmp/bench/anna && go build && cd ..
cd saaru && cargo build --release && mv ./target/release/saaru . && cd ..
echo "finished building"

## 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/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/hugo/content/test_$i.md"
cp /tmp/bench/test.md "/tmp/bench/11ty/test_$i.md"
done
sleep 1

# cooldown
echo "cooldown for 30s"
sleep 30

# 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/anna && hyperfine -p 'sync' -w $warm "./anna" && cd ..
cd saaru && hyperfine -p 'sync' -w $warm "./saaru --base-path ./docs" && cd ..
echo -e "\n"

0 comments on commit e4aae40

Please sign in to comment.