Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
989ddd2
chore: added package files
Nov 6, 2019
050e625
feat: added fixture data
Nov 6, 2019
440d567
feat: added initial 'base' (not real) results
Nov 6, 2019
33872ba
feat: added constants file
Nov 6, 2019
7d78ca6
feat: added npm command benchmark suite
Nov 6, 2019
3252e76
feat: added suite actions/helpers
Nov 6, 2019
756bd1d
feat: added common utils
Nov 6, 2019
9e81436
feat: added execution function
Nov 6, 2019
dca32ff
feat: added repo entrypoint
Nov 6, 2019
3436369
feat: added dedent, and octokit as deps
Nov 6, 2019
ad5faf9
feat: updated scripts in package file
Nov 6, 2019
cf7ba3d
feat: updated index to accempt command name; updated logging
Nov 6, 2019
8aaa278
feat: updated benchmark execution to handle writing multiple files; k…
Nov 6, 2019
e7ba5d4
feat: updated workflow handle two kinds of benchmarking scenarios
Nov 6, 2019
2f49fd5
feat: added comment function; added result parsing function
Nov 6, 2019
111b2db
chore: cleaned up logging
Nov 6, 2019
39c555a
feat: added pretty-ms dep for output to pull-requests
Nov 6, 2019
9c193b0
feat: updated result parsing logic
Nov 6, 2019
d3ac251
feat: updated results (from local machine; starting point)
Nov 6, 2019
6b4744d
fix: updated matrix in workflow
Nov 7, 2019
1036c66
chore: updated comment explaination
Nov 7, 2019
e1a2acf
fix: removed step used only for testing
Nov 7, 2019
84d3b30
fix: updated logging in utils file
Nov 7, 2019
8790f7e
fix: updated pull-request comment format to have a status emoji
Nov 7, 2019
7e3362a
chore: add todo about benchmark v2
Nov 7, 2019
4cbfb3b
chore: add todo/note about future fix
Nov 7, 2019
5b7643a
chore: add todo about future improvement
Nov 7, 2019
fb75d36
chore: add throw in catch block of execute; fix for loop
Nov 7, 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
Prev Previous commit
Next Next commit
feat: added npm command benchmark suite
  • Loading branch information
Michael Perrotte committed Nov 6, 2019
commit 7d78ca60ddaeed682dc258289ba7ecdaf64cab72
261 changes: 261 additions & 0 deletions lib/npm-suite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
'use strict'

const { join } = require('path')

const {
CACHE_NAME,
FIXTURES_DIR
} = require('./constants')

const {
createEnv,
removeCache,
removeNodeModules,
removeLockfile,
measureAction
} = require('./suite-actions')

/**
* NOTE: Scenario Ordering
* The first scenario needs to be an "initial install" to populate the cache,
* node_modules folder, and create a lockfile. All the subsequent scenarios
* can be in any order. As a subsequent scenario starts with populated cache,
* node_modules folder, and lockfile (created from the previous scenario),
* they mearly need to remove the idea they do not want.
*/
module.exports.suiteName = 'npm'
module.exports.suiteCmd = 'npm'
module.exports.scenarios = [
{
name: 'Initial install',
details: {
cache: false,
node_modules: false,
lockfile: false
},
cmd: 'npm',
args: [
'install',
'--ignore-scripts',
'--cache',
`${CACHE_NAME}`,
'--registry',
'https://registry.npmjs.org/'
],
actions: [
removeCache,
removeNodeModules,
removeLockfile,
async (ctx, fixture) => {
const { cmd, args } = ctx
const env = createEnv()

const cwd = join(FIXTURES_DIR, fixture)
return measureAction({ cmd, args, env, cwd })
}
]
},
{
name: 'Repeat install',
details: {
cache: true,
node_modules: true,
lockfile: true
},
cmd: 'npm',
args: [
'install',
'--ignore-scripts',
'--cache',
`${CACHE_NAME}`,
'--registry',
'https://registry.npmjs.org/'
],
actions: [
(ctx, fixture) => {
const { cmd, args } = ctx
const env = createEnv()

const cwd = join(FIXTURES_DIR, fixture)
return measureAction({ cmd, args, env, cwd })
}
]
},
{
name: 'With warm cache',
details: {
cache: true,
node_modules: false,
lockfile: false
},
cmd: 'npm',
args: [
'install',
'--ignore-scripts',
'--cache',
`${CACHE_NAME}`,
'--registry',
'https://registry.npmjs.org/'
],
actions: [
removeNodeModules,
removeLockfile,
(ctx, fixture) => {
const { cmd, args } = ctx
const env = createEnv()

const cwd = join(FIXTURES_DIR, fixture)
return measureAction({ cmd, args, env, cwd })
}
]
},
{
name: 'With node_modules',
details: {
cache: false,
node_modules: true,
lockfile: false
},
cmd: 'npm',
args: [
'install',
'--ignore-scripts',
'--cache',
`${CACHE_NAME}`,
'--registry',
'https://registry.npmjs.org/'
],
actions: [
removeCache,
removeLockfile,
(ctx, fixture) => {
const { cmd, args } = ctx
const env = createEnv()

const cwd = join(FIXTURES_DIR, fixture)
return measureAction({ cmd, args, env, cwd })
}
]
},
{
name: 'With lockfile',
details: {
cache: false,
node_modules: false,
lockfile: true
},
cmd: 'npm',
args: [
'install',
'--ignore-scripts',
'--cache',
`${CACHE_NAME}`,
'--registry',
'https://registry.npmjs.org/'
],
actions: [
removeCache,
removeNodeModules,
(ctx, fixture) => {
const { cmd, args } = ctx
const env = createEnv()

const cwd = join(FIXTURES_DIR, fixture)
return measureAction({ cmd, args, env, cwd })
}
]
},
{
name: 'With warm cache and node_modules',
details: {
cache: true,
node_modules: true,
lockfile: false
},
cmd: 'npm',
args: [
'install',
'--ignore-scripts',
'--cache',
`${CACHE_NAME}`,
'--registry',
'https://registry.npmjs.org/'
],
actions: [
removeLockfile,
(ctx, fixture) => {
const { cmd, args } = ctx
const env = createEnv()

const cwd = join(FIXTURES_DIR, fixture)
return measureAction({ cmd, args, env, cwd })
}
]
},
{
name: 'With warm cache and lockfile',
details: {
cache: true,
node_modules: false,
lockfile: true
},
cmd: 'npm',
args: [
'install',
'--ignore-scripts',
'--cache',
`${CACHE_NAME}`,
'--registry',
'https://registry.npmjs.org/'
],
actions: [
removeNodeModules,
(ctx, fixture) => {
const { cmd, args } = ctx
const env = createEnv()

const cwd = join(FIXTURES_DIR, fixture)
return measureAction({ cmd, args, env, cwd })
}
]
},
{
name: 'With node_modules and lockfile',
details: {
cache: false,
node_modules: true,
lockfile: true
},
cmd: 'npm',
args: [
'install',
'--ignore-scripts',
'--cache',
`${CACHE_NAME}`,
'--registry',
'https://registry.npmjs.org/'
],
actions: [
removeCache,
(ctx, fixture) => {
const { cmd, args } = ctx
const env = createEnv()

const cwd = join(FIXTURES_DIR, fixture)
return measureAction({ cmd, args, env, cwd })
}
]
},
{
name: 'cleanup',
details: {},
cmd: 'noop',
args: [],
actions: [
removeCache,
removeNodeModules,
removeLockfile,
(ctx, fixture) => 0
]
}
]