Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(benchmarks): add circleci job #20490

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,27 @@ jobs:
paths:
- "*"

run_benchmarks:
docker:
- image: circleci/node:12
resource_class: xlarge
steps:
- checkout
- run: ./scripts/build-benchmark.sh

workflows:
version: 2

run_benchmarks:
jobs: [run_benchmarks]
triggers:
- schedule:
cron: "12 3 * * *" # every day at 03:12
filters:
branches:
only:
- master

nightly-react-next:
triggers:
- schedule:
Expand Down
24 changes: 24 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Benchmarks

Example sites for benchmarking `gatsby`.

## Interface

The standard interface for running a benchmark is:

```
cd {benchmark directory}
export NUM_PAGES={n}
npm install
gatsby build
```

If a specific benchmark needs to perform some code generation (e.g. `markdown_id`),
that generation shall happen in a `postinstall` script.
Any `postinstall` script must ensure that previous benchmark runs do not interfere with the current run.

For example:

```
"postinstall": "del-cli ./generated && gatsby clean && npm run generate"
```
3 changes: 2 additions & 1 deletion benchmarks/markdown_id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"version": "0.0.1",
"author": "PvdZ <pvdz@github>",
"dependencies": {
"del-cli": "^3.0.0",
"gatsby": "*",
"gatsby-image": "*",
"gatsby-plugin-feed": "*",
Expand Down Expand Up @@ -51,6 +52,6 @@
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1",
"bench": "rm -r markdown-pages; NUM_PAGES=${NUM_PAGES:-2000} node md.generate.js; gatsby clean; node --max_old_space_size=2000 node_modules/.bin/gatsby build",
"benchnb": "gatsby clean; node --max_old_space_size=2000 node_modules/.bin/gatsby build",
"postinstall": "NUM_PAGES=${NUM_PAGES:-2000} node md.generate.js"
"postinstall": "del-cli markdown-pages && gatsby clean && NUM_PAGES=${NUM_PAGES:-2000} node md.generate.js"
}
}
3 changes: 2 additions & 1 deletion benchmarks/markdown_slug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"version": "0.0.1",
"author": "PvdZ <pvdz@github>",
"dependencies": {
"del-cli": "^3.0.0",
"gatsby": "*",
"gatsby-image": "*",
"gatsby-plugin-feed": "*",
Expand Down Expand Up @@ -51,6 +52,6 @@
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1",
"bench": "rm -r markdown-pages; NUM_PAGES=${NUM_PAGES:-2000} node md.generate.js; gatsby clean; node --max_old_space_size=2000 node_modules/.bin/gatsby build",
"benchnb": "gatsby clean; node --max_old_space_size=2000 node_modules/.bin/gatsby build",
"postinstall": "NUM_PAGES=${NUM_PAGES:-2000} node md.generate.js"
"postinstall": "del-cli markdown-pages && gatsby clean && NUM_PAGES=${NUM_PAGES:-2000} node md.generate.js"
}
}
33 changes: 33 additions & 0 deletions scripts/build-benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash -eux

set -e
set -u
set -x

BENCHMARKS=(
# create-pages
# image-processing
markdown_id
markdown_slug
markdown_table
# plugin-manifest
# query
)

SIZES=(
1000
5000
10000
25000
# 100000
)

cd benchmarks
for benchmark in "${BENCHMARKS[@]}"; do
cd "${benchmark}"
for num in "${SIZES[@]}"; do
NUM_PAGES=${num} npm install
NUM_PAGES=${num} ./node_modules/.bin/gatsby build
done
cd ..
done