OverviewFilesCommitsIssuesDocsReleasesPeers

pgh / test / bench / scenarios / transfer-2gb-many.scenario.js

42 lines · javascript ref:
/**
 * transfer-2gb-many — 2000 deps × 1 MB each.
 *
 * Same total bytes as transfer-2gb-blob, but spread across many small
 * trees + content blobs. Surfaces per-tree overhead:
 *   - 2000 tree fetches
 *   - 2000 content fetches
 *   - 2000 hardlink scratch dirs + symlink wiring
 *
 * If transfer-2gb-blob hits N MB/s and this hits much less, the
 * difference is the per-tree round-trip cost. If they're similar,
 * NetworkFetcher's raw throughput is the ceiling regardless of shape.
 */

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

const fixture = 'bench-many-2g'

export const name = 'transfer-2gb-many'
export const description = '2000 deps × 1 MB — metadata-heavy 2 GB transfer'

export async function setup (ctx) {
  if (!process.argv.includes('--enable-large')) {
    throw new Error('skipped (pass --enable-large to run)')
  }
  const { lockfile } = await publishFixture(ctx, fixture)
  ctx._lockfile = lockfile
  ctx.emit('fixture', fixture)
  ctx.emit('dep_count', lockfile.deps.length)
  ctx.emit('payload_bytes', 2 * 1024 * 1024 * 1024)
}

export async function run (ctx) {
  clearStore(ctx)
  const t0 = Date.now()
  await installByName(ctx, ctx._lockfile, fixture)
  const elapsedSec = (Date.now() - t0) / 1000
  ctx.emit('elapsed_sec', elapsedSec)
  ctx.emit('throughput_mb_per_s',
    Math.round((2 * 1024) / elapsedSec * 10) / 10)
}