OverviewFilesCommitsIssuesDocsReleasesPeers

pgh / test / bench / scenarios / cold-install.scenario.js

37 lines · javascript ref:
/**
 * cold-install — full install with an empty tree store.
 *
 * Measures the worst case: every dep must be fetched from the publisher
 * over the swarm, every byte goes over the wire, materialize is a
 * full hardlink + symlink wiring pass.
 *
 * Set FIXTURE env var to choose (default bench-medium):
 *   FIXTURE=bench-tiny    | bench-medium | bench-large
 *   FIXTURE=bench-blob-2g | bench-many-2g (long-running, gates on --enable-large)
 */

import { publishFixture, installByName, clearStore } from './_lib.js'

const fixture = process.env.FIXTURE || 'bench-medium'

export const name = 'cold-install/' + fixture
export const description = 'full install with empty tree-store (worst case)'

export async function setup (ctx) {
  // Build a fresh staging dir of the fixture and publish it. Publish
  // goes into the user's real release-registry; the install in run()
  // then fetches it back through the same path users hit. We can't
  // fully isolate publish today (see arch-critique doc, "publish-to-real-registry"
  // half-implemented item).
  const { lockfile } = await publishFixture(ctx, fixture)
  ctx.emit('fixture', fixture)
  ctx.emit('publish_dep_count', lockfile.deps.length)
  ctx.emit('publish_root_tree', lockfile.rootTreeHash.slice(0, 12))
  ctx._lockfile = lockfile
}

export async function run (ctx) {
  clearStore(ctx)
  await installByName(ctx, ctx._lockfile, fixture)
}