Skip to content

Commit

Permalink
ci: update bench
Browse files Browse the repository at this point in the history
  • Loading branch information
polarhive committed Jan 8, 2025
1 parent 0231d50 commit 24a0faa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 55 deletions.
48 changes: 3 additions & 45 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Benchmark anna v/s other SSGs
name: Benchmark

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

jobs:
benchmark:
Expand All @@ -15,7 +11,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Hyperfine
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y hyperfine
Expand All @@ -25,55 +21,17 @@ jobs:
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@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:
profile: minimal
toolchain: stable

- name: Install Dependencies
run: |
sudo apt-get install -y curl git
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
rustup default stable
rustup update
rustc --version
cargo --version
go version
- name: Run Benchmark
run: |
chmod +x test/bench.sh
./test/bench.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Test Workflow](https://github.com/anna-ssg/anna/actions/workflows/tests.yml/badge.svg)](https://github.com/anna-ssg/anna/actions/workflows/tests.yml)
[![Netlify Status](https://api.netlify.com/api/v1/badges/09b8bdf3-5931-4295-9fe7-d463d5d06a3f/deploy-status)](https://app.netlify.com/sites/anna-docs/deploys)
[![Go Reference](https://pkg.go.dev/badge/github.com/anna-ssg/anna.svg)](https://pkg.go.dev/github.com/anna-ssg/anna)
[![Go Reference](https://pkg.go.dev/badge/github.com/anna-ssg/v3/anna.svg)](https://pkg.go.dev/github.com/anna-ssg/anna/v3)
[![GitHub Repo Stars](https://img.shields.io/github/stars/anna-ssg/Anna?style=flat-square&label=Stars&color=lightgreen&logo=github)](https://github.com/anna-ssg/anna)

```text
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ require (
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.27.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {
var validateHTMLLayouts bool
var renderSpecificSite string

Version := "v2.0.0" // to be set at build time $(git describe --tags)
Version := "v3.0.0" // to be set at build time $(git describe --tags)

rootCmd := &cobra.Command{
Use: "anna",
Expand Down
18 changes: 11 additions & 7 deletions test/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ if ! command -v hugo &>/dev/null; then
fi

# cloning candidates
echo ""
echo "clone SSGs"
echo ""
git clone --depth=1 https://github.com/anna-ssg/anna /tmp/bench/anna
git clone --depth=1 https://github.com/anirudhRowjee/saaru /tmp/bench/saaru
git clone --depth=1 https://github.com/NavinShrinivas/sapling /tmp/bench/sapling

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

echo ""
echo "build SSGs"
echo ""
cd /tmp/bench/anna && go build && cd /tmp/bench

# build rust based SSGs (edit this block if they are already installed)
Expand All @@ -42,34 +46,34 @@ 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 ""
echo "Cleaning content directories"
echo ""
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 ""
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 ""
echo "running benchmark: $files md files and $warm warmup runs"
echo -e "\n"
echo ""
hyperfine -p 'sync' -w $warm \
# "cd /tmp/bench/11ty && npx @11ty/eleventy" \
"cd /tmp/bench/hugo && hugo" \
"cd /tmp/bench/anna && ./anna -r \"site/\"" \
"cd /tmp/bench/saaru && ./saaru --base-path ./docs" \
"cd /tmp/bench/sapling/benchmark && ./../sapling run"
echo -e "\n"
echo ""

0 comments on commit 24a0faa

Please sign in to comment.