@ac-bench/reporter-json 0.1.1 → 0.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @ac-bench/reporter-json
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 34e8cfa: Reports tell conditions apart. **`@ac-bench/reporter-json`** writes the archive
8
+ (`format: "ac-bench-archive"`, version 1) instead of one section per measure:
9
+ every condition keyed and titled, so two suites that each declare a case `new`
10
+ are two conditions, with the run, machine and runtime descriptions, and what a
11
+ gate reads: each execution's `processKey` and `observations` per gate metric,
12
+ each condition's `metrics`, the run's `gates` and `verdicts`, so
13
+ `@ac-bench/gate` evaluates it offline. It folds
14
+ events as they arrive and keeps no raw result, and writes nothing for a run that
15
+ described nothing (a listing). **Migration:** read `conditions[].cases[].result`
16
+ where you read `<measure>.conditions[]`. **`@ac-bench/reporter-markdown`** opens
17
+ with an environment section and renders one titled table per condition, its
18
+ heading on one line whatever the titles or file name hold.
19
+ **`@ac-bench/reporter-csv`** writes one table per condition, each row ending with
20
+ `runtime` and `condition` columns; a condition with no result is one row with
21
+ only those two filled. Neither asks a measure to conclude on a condition with
22
+ no result. **`@ac-bench/measure-duration`** leaves the
23
+ raw `timings` out of its JSON form unless the run was started with
24
+ `--emit-samples`; a six-case archive no longer weighs tens of megabytes.
25
+ **Duration, jitter, resource and constant-time** close a case that threw as
26
+ `failed` — its failure result is still reported — so the archive, the report
27
+ and the run's outcome count it as failed rather than measured.
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [34e8cfa]
32
+ - Updated dependencies [34e8cfa]
33
+ - Updated dependencies [34e8cfa]
34
+ - @ac-bench/core@0.3.0
35
+ - @ac-kit/app-report@0.3.0
36
+
3
37
  ## 0.1.1
4
38
 
5
39
  ### Patch Changes
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # @ac-bench/reporter-json
2
2
 
3
- Writes a benchmark run to a single JSON document, one section per measure, when
4
- the run ends. The section's shape is whatever the measure's own plugin produces:
5
- this reporter adds no schema of its own.
3
+ Writes a benchmark run to a single JSON document, the archive
4
+ (`format: "ac-bench-archive"`, version 1), when the run ends: the run's
5
+ description, the machine, the runtimes, and every condition with its titles,
6
+ the answer of each case and the executions behind it. A case's answer is
7
+ whatever the measure's own plugin produces for JSON; raw samples are left out
8
+ unless the run was started with `--emit-samples`.
6
9
 
7
10
  ```ts
8
11
  import { defineConfig } from "@ac-bench/cli";
package/dist/index.d.ts CHANGED
@@ -3,6 +3,9 @@ export type JsonReporterOptions = {
3
3
  /** Where to write. Default: the run's output base name plus `.json`. */
4
4
  readonly output?: string;
5
5
  };
6
- /** The whole run as one JSON document, written when the run ends. */
6
+ /**
7
+ * The whole run as one JSON archive (`BenchArchive`), written when the run
8
+ * ends.
9
+ */
7
10
  export default function jsonReporter(options?: JsonReporterOptions): ReporterPlugin;
8
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGX,cAAc,EACd,MAAM,uBAAuB,CAAC;AAS/B,MAAM,MAAM,mBAAmB,GAAG;IACjC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,qEAAqE;AACrE,MAAM,CAAC,OAAO,UAAU,YAAY,CACnC,OAAO,GAAE,mBAAwB,GAC/B,cAAc,CAShB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIzE,MAAM,MAAM,mBAAmB,GAAG;IACjC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CACnC,OAAO,GAAE,mBAAwB,GAC/B,cAAc,CAYhB"}
package/dist/index.js CHANGED
@@ -1,25 +1,37 @@
1
- import { buildConditionInput, defineReporterPlugin, groupCaseResultsByMeasure, } from "@ac-bench/core/plugin";
2
- import { AggregateSink } from "@ac-kit/app-report";
3
- /** The whole run as one JSON document, written when the run ends. */
1
+ import { ArchiveBuilder, defineReporterPlugin } from "@ac-bench/core/plugin";
2
+ /**
3
+ * The whole run as one JSON archive (`BenchArchive`), written when the run
4
+ * ends.
5
+ */
4
6
  export default function jsonReporter(options = {}) {
5
7
  return defineReporterPlugin({
6
8
  id: "json",
7
- createSink: (context) => new AggregateSink(context.openOutput(options.output ?? `${context.defaultOutput}.json`), formatJson_(context)),
9
+ createSink: (context) => new ArchiveSink_(new ArchiveBuilder({
10
+ registry: context.registry,
11
+ emitSamples: context.emitSamples === true,
12
+ }), context.openOutput(options.output ?? `${context.defaultOutput}.json`)),
8
13
  });
9
14
  }
10
- /** Serialises every measure present in `run` into one JSON document. */
11
- function formatJson_(context) {
12
- return (run) => {
13
- const merged = {};
14
- for (const [measureId, caseResults] of groupCaseResultsByMeasure(run.data)) {
15
- if (caseResults.length === 0) {
16
- continue;
17
- }
18
- const plugin = context.registry.resolve(measureId);
19
- const section = plugin.toJsonCondition(buildConditionInput(measureId, caseResults));
20
- Object.assign(merged, section);
15
+ /** Folds events into the archive as they come, and writes it once at close. */
16
+ class ArchiveSink_ {
17
+ builder;
18
+ writer;
19
+ constructor(builder, stream) {
20
+ this.builder = builder;
21
+ this.writer = stream.getWriter();
22
+ }
23
+ write(event) {
24
+ this.builder.write(event);
25
+ }
26
+ async flush() {
27
+ await this.writer.ready;
28
+ }
29
+ /** A run that described nothing (a listing) has no archive to write. */
30
+ async close() {
31
+ if (this.builder.described) {
32
+ await this.writer.write(`${JSON.stringify(this.builder.build(), null, 2)}\n`);
21
33
  }
22
- return `${JSON.stringify(merged, null, 2)}\n`;
23
- };
34
+ await this.writer.close();
35
+ }
24
36
  }
25
37
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOnD,qEAAqE;AACrE,MAAM,CAAC,OAAO,UAAU,YAAY,CACnC,OAAO,GAAwB,EAAE;IAEjC,OAAO,oBAAoB,CAAC;QAC3B,EAAE,EAAE,MAAM;QACV,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE,CACvB,IAAI,aAAa,CAChB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,OAAO,CAAC,EACrE,WAAW,CAAC,OAAO,CAAC,CACpB;KACF,CAAC,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,SAAS,WAAW,CACnB,OAAwB;IAExB,OAAO,CAAC,GAAG,EAAE,EAAE;QACd,MAAM,MAAM,GAA4B,EAAE,CAAC;QAE3C,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,yBAAyB,CAC/D,GAAG,CAAC,IAAI,CACR,EAAE,CAAC;YACH,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9B,SAAS;YACV,CAAC;YACD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACnD,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,CACrC,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,CAC3C,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAkC,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI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,IAAI,EAAE,CAAC,CAAC,IAAI,CACpD,CAAC;QACH,CAAC;QACD,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ac-bench/reporter-json",
3
- "version": "0.1.1",
4
- "description": "JSON reporter for @ac-bench: writes a run to a single document, one section per measure.",
3
+ "version": "0.2.0",
4
+ "description": "JSON reporter for @ac-bench: writes a run as one archive document, conditions titled and keyed, without raw samples unless asked.",
5
5
  "keywords": [
6
6
  "benchmark",
7
7
  "json",
@@ -43,21 +43,21 @@
43
43
  "prepack": "yarn build"
44
44
  },
45
45
  "dependencies": {
46
- "@ac-bench/core": "^0.2.0",
47
- "@ac-kit/app-report": "^0.2.0",
48
- "@types/web": "^0.0.362"
46
+ "@ac-bench/core": "^0.3.0",
47
+ "@ac-kit/app-report": "^0.3.0",
48
+ "@types/web": "^0.0.367"
49
49
  },
50
50
  "devDependencies": {
51
- "@ac-kit/model-dataset": "^0.1.0",
51
+ "@ac-kit/model-dataset": "^0.2.0",
52
52
  "@ac-kit/tsconfig": "0.1.0",
53
53
  "@ac-kit/typedoc-config": "0.1.0",
54
- "@ac-kit/vitest-config": "0.1.1",
54
+ "@ac-kit/vitest-config": "0.2.0",
55
55
  "@typescript/native": "typescript@7.0.2",
56
56
  "rimraf": "6.1.4",
57
57
  "typedoc": "0.28.20",
58
58
  "typescript": "@typescript/typescript6@6.0.2",
59
- "vite": "8.3.7",
60
- "vitest": "5.1.0"
59
+ "vite": "8.4.0",
60
+ "vitest": "5.1.2"
61
61
  },
62
62
  "engines": {
63
63
  "node": ">=24"