Skip to content

Commit

Permalink
Set up benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
louisescher committed Dec 22, 2024
1 parent 0a3b026 commit 967c560
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
2 changes: 2 additions & 0 deletions benchmarks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/
!.results/
24 changes: 24 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Benchmarks

A benchmark using [`hyperfine`](https://github.com/sharkdp/hyperfine?tab=readme-ov-file). Used for the data we display on [domainexpansion.gg](https://domainexpansion.gg).

## Getting Started

First, install [`hyperfine`](https://github.com/sharkdp/hyperfine?tab=readme-ov-file) for your system. You can find instructions in their README file. To make this benchmark, you also need to have `git` installed.

Once installed, run the `bench.sh` file in this directory.

## What we benchmark

We chose 6 open-source Astro projects with varying sizes:

1. [astro.build](https://astro.build), the official Astro website
2. [docs.astro.build](https://docs.astro.build), the Astro docs and probably the biggest Astro-powered repository out there due to its translations
3. [starlight.astro.build](https://starlight.astro.build), the documentation for Starlight to represent mid-scale documentation projects
4. [ui.studiocms.dev](https://ui.studiocms.dev), a small documentation with a lot of MDX components
5. [developers.cloudflare.com](https://developers.cloudflare.com), probably the biggest single-language Astro-powererd site
6. [brutal.elian.codes](https://brutal.elian.codes), a popular Astro theme and rather small project compared to the rest

## How we benchmark

First, all repositories are cloned. Afterwards, we go into the directory and run `astro build` once to populate the asset cache. Afterwards, we run `astro build` 10 times, which is `hyperfine`'s default. Once that is done, we add the `@domain-expansion/astro` integration and run `astro build` another 10 times, each time making sure we remove the cache that is created. Last but certainly not least, we run `astro build` without removing the cache first, yet another 10 times. After all benchmarks have concluded, we move on to the next repository.
118 changes: 118 additions & 0 deletions benchmarks/bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#! /usr/bin/bash

rm -rf */

mkdir .results

ROOT="$PWD"

# git clone --depth 1 https://github.com/withastro/docs &
# git clone --depth 1 https://github.com/zen-browser/www zen-browser &
git clone --depth 1 https://github.com/withstudiocms/ui &
# git clone --depth 1 https://github.com/eliancodes/brutal &
# git clone --depth 1 https://github.com/withastro/starlight &
# git clone --depth 1 https://github.com/cloudflare/cloudflare-docs &

wait

# cd docs

# export NODE_OPTIONS=--max-old-space-size=8192
# export SKIP_OG=true

# pnpm install
# pnpm build # Used as warmup to populate asset cache

# hyperfine \
# --export-markdown ../.results/astro-docs.md \
# --runs 3 \
# -n '[Astro Docs] Normal Build' \
# 'pnpm build' \
# --prepare 'pnpm astro add @domain-expansion/astro -y && rm -rf ./node_modules/.domain-expansion' \
# -n '[Astro Docs] Domain Expansion (cold build)' \
# 'pnpm build' \
# -n '[Astro Docs] Domain Expansion (hot build)' \
# 'pnpm build' &

# cd ../zen-browser

# pnpm install
# pnpm build # Used as warmup to populate asset cache

# hyperfine \
# --export-markdown ../.results/zen-browser.md \
# -n '[Zen Browser Website] Normal Build' \
# 'pnpm build' \
# --prepare 'pnpm astro add @domain-expansion/astro -y && rm -rf ./node_modules/.domain-expansion' \
# -n '[Zen Browser Website] Domain Expansion (cold build)' \
# 'pnpm build' \
# -n '[Zen Browser Website] Domain Expansion (hot build)' \
# 'pnpm build' &

# cd ../ui/docs

cd ui/docs

pnpm install
pnpm build # Used as warmup to populate asset cache

hyperfine \
--export-markdown ../../.results/studiocms-ui.md \
-n '[StudioCMS UI Docs] Normal Build' \
'pnpm build' \
--prepare 'pnpm astro add @domain-expansion/astro -y && rm -rf ./node_modules/.domain-expansion' \
-n '[StudioCMS UI Docs] Domain Expansion (cold build)' \
'pnpm build' \
-n '[StudioCMS UI Docs] Domain Expansion (hot build)' \
'pnpm build' &

# cd ../../brutal

# pnpm install
# pnpm build # Used as warmup to populate asset cache

# hyperfine \
# --export-markdown ../.results/brutal.md \
# -n '[Brutal Theme] Normal Build' \
# 'pnpm build' \
# --prepare 'pnpm astro add @domain-expansion/astro -y && rm -rf ./node_modules/.domain-expansion' \
# -n '[Brutal Theme] Domain Expansion (cold build)' \
# 'pnpm build' \
# -n '[Brutal Theme] Domain Expansion (hot build)' \
# 'pnpm build' &

# cd ../starlight/docs

# pnpm install
# pnpm build # Used as warmup to populate asset cache

# hyperfine \
# --export-markdown ../../.results/starlight.md \
# -n '[Starlight Docs] Normal Build' \
# 'pnpm build' \
# --prepare 'pnpm astro add @domain-expansion/astro -y && rm -rf ./node_modules/.domain-expansion' \
# -n '[Starlight Docs] Domain Expansion (cold build)' \
# 'pnpm build' \
# -n '[Starlight Docs] Domain Expansion (hot build)' \
# 'pnpm build' &

# cd ../../cloudflare-docs

# npm install
# npm run build # Used as warmup to populate asset cache

# hyperfine \
# --export-markdown ../.results/cloudflare-docs.md \
# -n '[Cloudflare Docs] Normal Build' \
# 'npm run build' \
# --prepare 'npx astro add @domain-expansion/astro -y && rm -rf ./node_modules/.domain-expansion' \
# -n '[Cloudflare Docs] Domain Expansion (cold build)' \
# 'npm run build' \
# -n '[Cloudflare Docs] Domain Expansion (hot build)' \
# 'npm run build' &

wait

cd "$ROOT"

rm -rf */

0 comments on commit 967c560

Please sign in to comment.