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

refactor(gatsby-plugin-manifest): misc code and doc updates #12757

Merged
merged 21 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
351da25
feat: add better logging
moonmeister Mar 22, 2019
a964c7e
refactor: update to es6 import and finish async/await conversion to d…
moonmeister Mar 22, 2019
ddfa607
test: fix tests to work with reporter
moonmeister Mar 22, 2019
e9e7496
docs: rework the docs to be more useable and flow better
moonmeister Mar 22, 2019
3e88d49
docs: some editing and additional documentation
moonmeister Mar 23, 2019
a293418
docs: fix some header formats and other misc edits and formatting
moonmeister Mar 23, 2019
f366389
fix: bugs in 'icon_options' implementation
moonmeister Mar 27, 2019
a58b586
fix: make icons array take presidence over icon_options
moonmeister Mar 27, 2019
dc550cb
test: write icon_options tests and fix bug
moonmeister Mar 27, 2019
5136f1d
Revert "test: write icon_options tests and fix bug"
moonmeister Mar 28, 2019
dec9e8d
Revert "fix: make icons array take presidence over icon_options"
moonmeister Mar 28, 2019
60e67f0
Revert "fix: bugs in 'icon_options' implementation"
moonmeister Mar 28, 2019
4a0f34b
refactor: switch let to const as allowed
moonmeister Mar 28, 2019
286cc5c
test: organize ssr tests and add missing
moonmeister Mar 28, 2019
f1eebef
fix: bug with cache busting happening in manual mode on legacy icons
moonmeister Mar 28, 2019
344f990
fix: fix include_favicon not being removed from manifest and add test
moonmeister Mar 28, 2019
6a75dc6
test: add manifest benchmark for testing execution time of 'onPostBoo…
moonmeister Mar 29, 2019
a774614
Merge branch 'master' into manifest-cleanup
wardpeet Mar 29, 2019
456c7f0
fix small nits
wardpeet Apr 8, 2019
9d28574
move to createContentDigest helper
wardpeet Apr 8, 2019
87b5400
fix imporrt createConentDigest
wardpeet Apr 8, 2019
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
21 changes: 21 additions & 0 deletions benchmarks/plugin-manifest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# gatsby-plugin-manifest performance tests

- Setup: `yarn`
- Run: `yarn test`

Benchmarks the current production version of the plugin unless you use `gatsby-dev`.

## To benchmark the current branch:

```sh
# In the root of the Gatsby repository
$ yarn run watch --scope=gatsby-plugin-manifest .
```

```sh
# In ./benchmarks/plugin-manifest
# You'll need 'gatsby-dev' installed and configured globally.
$ gatsby-dev --packages gatsby-plugin-manifest
```

You may now switch branches using `git checkout` and edit code on the current branch. Changes will be compiled into the local `node_modules` for the benchmark.
77 changes: 77 additions & 0 deletions benchmarks/plugin-manifest/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const { onPostBootstrap } = require(`gatsby-plugin-manifest/gatsby-node`)
const reporter = require(`gatsby-cli/lib/reporter`)
const fs = require(`fs-extra`)

//Config for executing onPostBootstrap
const pluginOptions = {
name: `GatsbyJS`,
short_name: `GatsbyJS`,
start_url: `/`,
background_color: `#ffffff`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `../../www/src/assets/gatsby-icon.png`,
cache_busting_mode: `none`,
}

//Global Variables
let results = { seconds: [], nanoseconds: [] }
let sum = [0, 0]
let rounds = process.env.TOTAL_ROUNDS || 20

//Execute a single test of onPostBootstrap
async function executeBootstrap() {
const timeStart = process.hrtime()
await onPostBootstrap({ reporter }, pluginOptions)
const timeEnd = process.hrtime(timeStart)

// console.info(
// "Execution time (hr): %ds %dms",
// timeEnd[0],
// timeEnd[1] / 1000000
// )

results.seconds.push(timeEnd[0])
results.nanoseconds.push(timeEnd[1])
sum[0] += timeEnd[0]
sum[1] += timeEnd[1]

fs.removeSync(`public/icons`)
fs.removeSync(`public/manifest.webmanifest`)
}

//Loop test to run multiple times and calculate results
async function runTest() {
console.info(`Timing 'onPostBootstrap' running ${rounds} times.`)

for (let i = 0; i < rounds; i++) {
// process.stdout.write(`Round ${i + 1}: `)
await executeBootstrap(i)
}

let averageSum = [0, 0]
averageSum[0] = sum[0] / rounds
averageSum[1] = sum[1] / rounds

console.info(
`\nAverage execution time (hr): %ds %dms`,
averageSum[0],
averageSum[1] / 1000000
)

console.info(
`\nMax execution time (hr): ${Math.max(...results.nanoseconds) / 1000000}ms`
)
console.info(
`\nMin execution time (hr): ${Math.min(...results.nanoseconds) / 1000000}ms`
)

console.info(
`\nRange execution time (hr): ${(Math.max(...results.nanoseconds) -
Math.min(...results.nanoseconds)) /
1000000}ms`
)
}

//execute
runTest()
15 changes: 15 additions & 0 deletions benchmarks/plugin-manifest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "benchmark-gatsby-plugin-manifest",
"version": "1.0.0",
"description": "Run manifest lots of times",
"main": "index.js",
"scripts": {
"test": "node index.js"
},
"author": "Alex Moon <[email protected]",
"license": "MIT",
"dependencies": {
"fs-extra": "^7.0.1",
"gatsby-plugin-manifest": "^2.0.25"
}
}
Empty file.
Loading