OverviewFilesCommitsIssuesDocsReleasesPeers

pgh / test / bench / scenarios / partial-cache.scenario.js

35 lines · javascript ref:
/**
 * partial-cache — install with ~half of deps cached, half evicted.
 *
 * The realistic case for app updates: most deps haven't changed since
 * the previous install, but some have. Measures the dep-loop's ability
 * to short-circuit cached entries while fetching the missing ones.
 *
 * Bottleneck this surfaces: B1 (sequential dep loop). Should be
 * roughly half the cold-install time post-fix.
 */

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

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

export const name = 'partial-cache/' + fixture
export const description = 'install with ~50% of deps already in store'

export async function setup (ctx) {
  const { lockfile } = await publishFixture(ctx, fixture)
  ctx._lockfile = lockfile
  ctx.emit('fixture', fixture)
  // Full warm install to seed the store with everything.
  await installByName(ctx, lockfile, fixture)
  // Wipe the install dir and ~half the store.
  clearApp(ctx, fixture)
  const evicted = evictHalfStore(ctx)
  ctx.emit('evicted_count', evicted)
}

export async function run (ctx) {
  ctx.metrics.install_duration_ms = null
  await installByName(ctx, ctx._lockfile, fixture)
}