@benchsdk/runner 0.2.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # @benchsdk/runner
2
2
 
3
- Benchmark framework for authoring `*.bench.ts` files that report to the benchmarks platform via [`@benchsdk/client`](../benchsdk).
3
+ Benchmark framework for authoring `*.bench.ts` files and operating benchmark workers. It reports to the benchmarks platform via `@benchsdk/api`; [`@benchsdk/client`](../benchsdk) is a backwards-compatibility re-export shim.
4
4
 
5
5
  ## What it provides
6
6
 
7
7
  - **`defineBenchmarkConfig`** / **`defineTask`** — A `*.bench.ts` file exports exactly two things: a **config** (`defineBenchmarkConfig`, the orchestration knobs + `participants` + an optional `onComplete` hook) and a **task** (`defineTask`, the workload for one iteration). There is no "mode": the orchestration shape (sequential / staggered / burst) emerges from the `iterations`, `concurrency`, and `staggerDelayMs` knobs, and `groupBy` (`'participant'` | `'round'`) selects the ordering across participants.
8
8
  - **`bench run <file>`** — The CLI entrypoint. It imports the module, reads its `config` and `task`, applies CLI overrides, and drives the run. Benchmark files declare; they never call the runner themselves.
9
+ - **`bench check <file>`** — Validates environment variables, API connectivity, participant availability, and scoring weights before a run.
10
+ - **`runBenchmarkWorker(options)`** — One-shot operator helper that runs a single participant's worker without a `*.bench.ts` file.
9
11
  - **`TaskError`** / **`NoAvailableParticipantsError`** — Structured errors: throw `TaskError` from a task to attach a code / data / pre-measured steps; `bench run` treats `NoAvailableParticipantsError` (every participant env-gated out) as a clean no-op exit.
10
12
 
11
13
  ## Install
@@ -34,10 +36,11 @@ export const config = defineBenchmarkConfig({
34
36
  });
35
37
 
36
38
  export const task = defineTask(async ({ participant, step, measure, log }) => {
37
- log(`creating sandbox on ${participant.name}`);
39
+ log('creating sandbox', { level: 'info', meta: { participant: participant.name } });
38
40
  // Named steps via `ctx.step`: values flow between steps with closures and
39
41
  // cleanup runs in a `finally`. Each step is a first-class platform record
40
- // with its own timing/status.
42
+ // with its own timing/status. A step returning `{ stdout, stderr, exitCode }`
43
+ // writes that output to the worker log unless `captureOutput: false` is passed.
41
44
  const sandbox = await step('create', () => participant.createCompute().sandbox.create());
42
45
  try {
43
46
  const t0 = performance.now();
@@ -55,6 +58,8 @@ Run it with the CLI (flags override the config knobs):
55
58
  bench run benchmarks/sandbox/sandbox-tti.bench.ts --iterations 100 --concurrency 20 --provider e2b,modal
56
59
  ```
57
60
 
61
+ `bench run` requires platform auth — `BENCHMARKS_PLATFORM_API_KEY`, `BENCHMARKS_PLATFORM_TOKEN`, or a token saved via `bench auth login` — even for `--dry-run` / `--no-ingest` / `BENCHSDK_NO_INGEST=1`; those flags only skip uploading, they do not skip auth.
62
+
58
63
  To load a TypeScript benchmark without a build step, run the CLI under a TS loader:
59
64
 
60
65
  ```sh
@@ -65,9 +70,29 @@ tsx node_modules/@benchsdk/runner/dist/bin.js run sandbox-tti.bench.ts
65
70
 
66
71
  Inside a task the context exposes three separate channels:
67
72
 
68
- - **`step(name, fn, options?)`** — returns `fn`'s value to your code (thread live objects between steps); records the step's timing/status on the platform. Return values are never auto-recorded as data.
73
+ - **`step(name, fn, options?)`** — returns `fn`'s value to your code (thread live objects between steps); records the step's timing/status on the platform. Return values are never auto-recorded as data. Set `captureOutput: false` to return an outcome-shaped object (`stdout`, `stderr`, `exitCode`, ...) without writing it to the worker log. Use `parallelInvocations` (formerly `concurrency`) to invoke a step multiple times in parallel.
69
74
  - **`measure(data)`** — explicit metric channel. Called inside a `step()` it merges into that step's data; called at task top-level it merges into the task record. A task with no explicit steps is recorded as one implicit `'task'` step carrying its measurements.
70
- - **`log(message, meta?)`** — human-readable narration to the run timeline.
75
+ - **`log(message, metaOrOptions?)`** — human-readable narration to the run timeline. `metaOrOptions` can be a metadata JSON object or `{ level: 'debug' | 'info' | 'warn' | 'error', meta?: JsonObject }`.
76
+
77
+ ## Platform data commands
78
+
79
+ `bench` is a unified CLI. Besides `bench run`, it can authenticate and query the platform:
80
+
81
+ ```sh
82
+ bench check <file.bench.ts>
83
+ bench auth login
84
+ bench benchmarks list
85
+ bench runs list <slug>
86
+ bench results <slug> --run <runId>
87
+ bench artifacts list <slug> <runId>
88
+ bench export <slug> --out ./exports
89
+ ```
90
+
91
+ See the [benchsdk-cli skill](../../.agents/skills/benchsdk-cli/SKILL.md) for the full CLI reference, OAuth device-code login, config/credentials files, and CI use.
92
+
93
+ ## Examples and full guide
94
+
95
+ For a step-by-step authoring guide and runnable examples covering every capability, see [`WRITING_BENCHMARKS.md`](../../WRITING_BENCHMARKS.md) and the [`examples/`](../../examples) directory.
71
96
 
72
97
  ## License
73
98