From 967c5606d657ab3b7e3a55e31e16a6537e4fc161 Mon Sep 17 00:00:00 2001 From: Louis Escher Date: Sun, 22 Dec 2024 15:18:33 +0100 Subject: [PATCH] Set up benchmarks --- benchmarks/.gitignore | 2 + benchmarks/README.md | 24 +++++++++ benchmarks/bench.sh | 118 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 benchmarks/.gitignore create mode 100644 benchmarks/README.md create mode 100644 benchmarks/bench.sh diff --git a/benchmarks/.gitignore b/benchmarks/.gitignore new file mode 100644 index 0000000..d719488 --- /dev/null +++ b/benchmarks/.gitignore @@ -0,0 +1,2 @@ +*/ +!.results/ \ No newline at end of file diff --git a/benchmarks/README.md b/benchmarks/README.md new file mode 100644 index 0000000..8487822 --- /dev/null +++ b/benchmarks/README.md @@ -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. \ No newline at end of file diff --git a/benchmarks/bench.sh b/benchmarks/bench.sh new file mode 100644 index 0000000..cf893eb --- /dev/null +++ b/benchmarks/bench.sh @@ -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 */ \ No newline at end of file