@ac-bench/reporter-markdown 0.1.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/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024-2026 Anthony Champagne and contributors
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # @ac-bench/reporter-markdown
2
+
3
+ Writes a benchmark run as a GitHub-flavoured Markdown document, one table per
4
+ measure, when the run ends. Suited to pasting into a pull request or committing
5
+ next to the code the numbers describe.
6
+
7
+ ```ts
8
+ import { defineConfig } from "@ac-bench/cli";
9
+ import markdownReporter from "@ac-bench/reporter-markdown";
10
+
11
+ export default defineConfig({
12
+ plugins: [markdownReporter({ output: "docs/benchmarks.md" })],
13
+ reporters: ["markdown"],
14
+ });
15
+ ```
16
+
17
+ `output` defaults to the run's output base name plus `.md`. The default export
18
+ is a factory because there is something to configure; call it with no arguments
19
+ for the defaults.
20
+
21
+ `@ac-bench/cli` already depends on this package and selects it by id, so listing
22
+ it in `plugins` is only necessary to pass options.
@@ -0,0 +1,8 @@
1
+ import type { ReporterPlugin } from "@ac-bench/core/plugin";
2
+ export type MarkdownReporterOptions = {
3
+ /** Where to write. Default: the run's output base name plus `.md`. */
4
+ readonly output?: string;
5
+ };
6
+ /** The whole run as one GitHub-flavoured Markdown document. */
7
+ export default function markdownReporter(options?: MarkdownReporterOptions): ReporterPlugin;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGX,cAAc,EACd,MAAM,uBAAuB,CAAC;AAW/B,MAAM,MAAM,uBAAuB,GAAG;IACrC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,+DAA+D;AAC/D,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACvC,OAAO,GAAE,uBAA4B,GACnC,cAAc,CAShB"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ import { buildConditionInput, conditionFrame, defineReporterPlugin, groupCaseResultsByMeasure, } from "@ac-bench/core/plugin";
2
+ import { AggregateSink } from "@ac-kit/app-report";
3
+ import { renderFrameAsMarkdown } from "@ac-kit/format-markdown";
4
+ /** The whole run as one GitHub-flavoured Markdown document. */
5
+ export default function markdownReporter(options = {}) {
6
+ return defineReporterPlugin({
7
+ id: "markdown",
8
+ createSink: (context) => new AggregateSink(context.openOutput(options.output ?? `${context.defaultOutput}.md`), { formatter: formatMarkdown_(context) }),
9
+ });
10
+ }
11
+ /** Renders every measure present in `run`, one section each. */
12
+ function formatMarkdown_(context) {
13
+ return (run) => {
14
+ const sections = [];
15
+ for (const [measureId, caseResults] of groupCaseResultsByMeasure(run.data)) {
16
+ if (caseResults.length === 0) {
17
+ continue;
18
+ }
19
+ const plugin = context.registry.resolve(measureId);
20
+ const frame = conditionFrame(plugin, buildConditionInput(measureId, caseResults));
21
+ sections.push(renderFrameAsMarkdown(frame));
22
+ }
23
+ return `${sections.join("\n\n")}\n`;
24
+ };
25
+ }
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAOhE,+DAA+D;AAC/D,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACvC,OAAO,GAA4B,EAAE;IAErC,OAAO,oBAAoB,CAAC;QAC3B,EAAE,EAAE,UAAU;QACd,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE,CACvB,IAAI,aAAa,CAChB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,KAAK,CAAC,EACnE,EAAE,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CACvC;KACF,CAAC,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,SAAS,eAAe,CACvB,OAAwB;IAExB,OAAO,CAAC,GAAG,EAAE,EAAE;QACd,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,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,KAAK,GAAG,cAAc,CAC3B,MAAM,EACN,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,CAC3C,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACrC,CAAC,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@ac-bench/reporter-markdown",
3
+ "version": "0.1.0",
4
+ "description": "Markdown reporter for @ac-bench: writes a run as a GitHub-flavoured document, one table per measure.",
5
+ "keywords": [
6
+ "benchmark",
7
+ "gfm",
8
+ "markdown",
9
+ "reporter"
10
+ ],
11
+ "homepage": "https://github.com/anthochamp/node-essentials/tree/main/bench/reporter-markdown#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/anthochamp/node-essentials/issues"
14
+ },
15
+ "license": "BSD-3-Clause",
16
+ "author": "Anthony Champagne <dev@anthonychampagne.fr>",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/anthochamp/node-essentials.git",
20
+ "directory": "bench/reporter-markdown"
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "type": "module",
26
+ "sideEffects": false,
27
+ "main": "./dist/index.js",
28
+ "exports": {
29
+ ".": "./dist/index.js"
30
+ },
31
+ "publishConfig": {
32
+ "main": "./dist/index.js",
33
+ "exports": {
34
+ ".": "./dist/index.js"
35
+ },
36
+ "access": "public"
37
+ },
38
+ "scripts": {
39
+ "compile": "tsc -p ./tsconfig.build.json --outDir dist",
40
+ "compile:check": "tsc -noEmit -p ./tsconfig.json",
41
+ "clean": "rimraf dist",
42
+ "build": "yarn clean && yarn compile",
43
+ "test": "yarn run -T vitest run",
44
+ "prepack": "yarn build"
45
+ },
46
+ "dependencies": {
47
+ "@ac-bench/core": "^0.1.0",
48
+ "@ac-kit/app-report": "^0.1.0",
49
+ "@ac-kit/format-markdown": "^0.1.0",
50
+ "@types/web": "^0.0.354"
51
+ },
52
+ "devDependencies": {
53
+ "@ac-kit/model-dataset": "^0.1.0",
54
+ "@ac-kit/tsconfig": "0.1.0",
55
+ "@ac-kit/typedoc-config": "0.1.0",
56
+ "@ac-kit/vitest-config": "0.1.0",
57
+ "@typescript/native": "typescript@7.0.2",
58
+ "rimraf": "6.1.3",
59
+ "typedoc": "0.28.20",
60
+ "typescript": "@typescript/typescript6@6.0.2",
61
+ "vite": "8.3.0",
62
+ "vitest": "5.0.0"
63
+ },
64
+ "engines": {
65
+ "node": ">=24"
66
+ }
67
+ }