modestbench 0.7.0 → 0.8.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli/commands/run.cjs +89 -49
  3. package/dist/cli/commands/run.cjs.map +1 -1
  4. package/dist/cli/commands/run.d.cts.map +1 -1
  5. package/dist/cli/commands/run.d.ts.map +1 -1
  6. package/dist/cli/commands/run.js +90 -50
  7. package/dist/cli/commands/run.js.map +1 -1
  8. package/dist/constants.cjs +2 -0
  9. package/dist/constants.cjs.map +1 -1
  10. package/dist/constants.d.cts +2 -0
  11. package/dist/constants.d.cts.map +1 -1
  12. package/dist/constants.d.ts +2 -0
  13. package/dist/constants.d.ts.map +1 -1
  14. package/dist/constants.js +2 -0
  15. package/dist/constants.js.map +1 -1
  16. package/dist/errors/index.cjs +3 -1
  17. package/dist/errors/index.cjs.map +1 -1
  18. package/dist/errors/index.d.cts +1 -1
  19. package/dist/errors/index.d.cts.map +1 -1
  20. package/dist/errors/index.d.ts +1 -1
  21. package/dist/errors/index.d.ts.map +1 -1
  22. package/dist/errors/index.js +1 -1
  23. package/dist/errors/index.js.map +1 -1
  24. package/dist/errors/reporter.cjs +45 -1
  25. package/dist/errors/reporter.cjs.map +1 -1
  26. package/dist/errors/reporter.d.cts +32 -0
  27. package/dist/errors/reporter.d.cts.map +1 -1
  28. package/dist/errors/reporter.d.ts +32 -0
  29. package/dist/errors/reporter.d.ts.map +1 -1
  30. package/dist/errors/reporter.js +42 -0
  31. package/dist/errors/reporter.js.map +1 -1
  32. package/dist/index.cjs +16 -1
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +3 -1
  35. package/dist/index.d.cts.map +1 -1
  36. package/dist/index.d.ts +3 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +5 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/services/reporter-loader.cjs +281 -0
  41. package/dist/services/reporter-loader.cjs.map +1 -0
  42. package/dist/services/reporter-loader.d.cts +67 -0
  43. package/dist/services/reporter-loader.d.cts.map +1 -0
  44. package/dist/services/reporter-loader.d.ts +67 -0
  45. package/dist/services/reporter-loader.d.ts.map +1 -0
  46. package/dist/services/reporter-loader.js +241 -0
  47. package/dist/services/reporter-loader.js.map +1 -0
  48. package/dist/types/index.cjs.map +1 -1
  49. package/dist/types/index.d.cts +1 -0
  50. package/dist/types/index.d.cts.map +1 -1
  51. package/dist/types/index.d.ts +1 -0
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/dist/types/index.js.map +1 -1
  54. package/dist/types/plugin.cjs +9 -0
  55. package/dist/types/plugin.cjs.map +1 -0
  56. package/dist/types/plugin.d.cts +179 -0
  57. package/dist/types/plugin.d.cts.map +1 -0
  58. package/dist/types/plugin.d.ts +179 -0
  59. package/dist/types/plugin.d.ts.map +1 -0
  60. package/dist/types/plugin.js +8 -0
  61. package/dist/types/plugin.js.map +1 -0
  62. package/dist/utils/package.cjs +66 -5
  63. package/dist/utils/package.cjs.map +1 -1
  64. package/dist/utils/package.d.cts +6 -0
  65. package/dist/utils/package.d.cts.map +1 -1
  66. package/dist/utils/package.d.ts +6 -0
  67. package/dist/utils/package.d.ts.map +1 -1
  68. package/dist/utils/package.js +31 -1
  69. package/dist/utils/package.js.map +1 -1
  70. package/dist/utils/reporter-utils.cjs +90 -0
  71. package/dist/utils/reporter-utils.cjs.map +1 -0
  72. package/dist/utils/reporter-utils.d.cts +42 -0
  73. package/dist/utils/reporter-utils.d.cts.map +1 -0
  74. package/dist/utils/reporter-utils.d.ts +42 -0
  75. package/dist/utils/reporter-utils.d.ts.map +1 -0
  76. package/dist/utils/reporter-utils.js +83 -0
  77. package/dist/utils/reporter-utils.js.map +1 -0
  78. package/package.json +4 -4
  79. package/src/cli/commands/run.ts +127 -68
  80. package/src/constants.ts +2 -0
  81. package/src/errors/index.ts +2 -0
  82. package/src/errors/reporter.ts +55 -0
  83. package/src/index.ts +19 -1
  84. package/src/services/reporter-loader.ts +323 -0
  85. package/src/types/index.ts +3 -0
  86. package/src/types/plugin.ts +197 -0
  87. package/src/utils/package.ts +32 -1
  88. package/src/utils/reporter-utils.ts +85 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter-loader.js","sourceRoot":"","sources":["../../src/services/reporter-loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,OAAO,EAAE,SAAS,EAAE,wBAAwB;AAC5C,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,8BAA8B;AAC/B,OAAO,EAAE,iBAAiB,EAAE,4BAA4B;AACxD,OAAO,EAAE,aAAa,EAAE,mCAAmC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC;;GAEG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,yBAAyB,GAAG;IAChC,SAAS;IACT,OAAO;IACP,SAAS;IACT,cAAc;CACN,CAAC;AAEX;;;;GAIG;AACH,MAAM,aAAa,GAAW;IAC5B,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5D,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5D,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC1D,KAAK,EAAE,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C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;AAIH,6CAA6C;AAC7C,sCAAsD;AAA7C,sGAAA,WAAW,OAAA;AAAE,uGAAA,YAAY,OAAA;AAQlC,4BAA4B;AAC5B,gDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;AAIH,6CAA6C;AAC7C,sCAAsD;AAA7C,sGAAA,WAAW,OAAA;AAAE,uGAAA,YAAY,OAAA;AAWlC,4BAA4B;AAC5B,gDAA6B"}
@@ -7,6 +7,7 @@
7
7
  export type * from "./core.cjs";
8
8
  export { createRunId, createTaskId } from "./core.cjs";
9
9
  export type * from "./interfaces.cjs";
10
+ export type * from "./plugin.cjs";
10
11
  export type * from "./profiler.cjs";
11
12
  export * from "./utility.cjs";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,gCAA+B;AAE/B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAkB;AAGtD,sCAAqC;AAGrC,oCAAmC;AAGnC,8BAA6B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,gCAA+B;AAE/B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAkB;AAGtD,sCAAqC;AAGrC,kCAAiC;AAGjC,oCAAmC;AAGnC,8BAA6B"}
@@ -7,6 +7,7 @@
7
7
  export type * from "./core.js";
8
8
  export { createRunId, createTaskId } from "./core.js";
9
9
  export type * from "./interfaces.js";
10
+ export type * from "./plugin.js";
10
11
  export type * from "./profiler.js";
11
12
  export * from "./utility.js";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,+BAA+B;AAE/B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB;AAGtD,qCAAqC;AAGrC,mCAAmC;AAGnC,6BAA6B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,+BAA+B;AAE/B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB;AAGtD,qCAAqC;AAGrC,iCAAiC;AAGjC,mCAAmC;AAGnC,6BAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,6CAA6C;AAC7C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB;AAQtD,4BAA4B;AAC5B,6BAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,6CAA6C;AAC7C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB;AAWtD,4BAA4B;AAC5B,6BAA6B"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * ModestBench Plugin Types
4
+ *
5
+ * Type definitions for third-party reporter plugins. These types are exported
6
+ * from the main package for use by plugin authors.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * ModestBench Plugin Types
3
+ *
4
+ * Type definitions for third-party reporter plugins. These types are exported
5
+ * from the main package for use by plugin authors.
6
+ */
7
+ import type { Reporter } from "./interfaces.cjs";
8
+ import type { Logger } from "./utility.cjs";
9
+ /**
10
+ * Class constructor for reporter plugins
11
+ *
12
+ * Plugin authors can export a default class matching this signature. The class
13
+ * constructor receives options from the config file and a context object with
14
+ * utilities.
15
+ *
16
+ * @example
17
+ *
18
+ * ```typescript
19
+ * import type { Reporter, ReporterContext } from 'modestbench';
20
+ *
21
+ * interface MyReporterOptions {
22
+ * verbose?: boolean;
23
+ * outputFormat?: 'text' | 'markdown';
24
+ * }
25
+ *
26
+ * class MyReporter implements Reporter {
27
+ * constructor(
28
+ * private options: MyReporterOptions,
29
+ * private context: ReporterContext,
30
+ * ) {}
31
+ *
32
+ * onStart(run) {
33
+ * if (this.options.verbose) console.log('Starting');
34
+ * }
35
+ * onEnd(run) {
36
+ * console.log('Done');
37
+ * }
38
+ * onError(error) {
39
+ * console.error(error);
40
+ * }
41
+ * onTaskResult(result) {
42
+ * console.log(
43
+ * `${result.name}: ${this.context.utils.formatDuration(result.mean)}`,
44
+ * );
45
+ * }
46
+ * }
47
+ *
48
+ * export default MyReporter;
49
+ * ```
50
+ *
51
+ * @typeParam TOptions - The shape of the options object (defaults to
52
+ * Record<string, unknown>)
53
+ */
54
+ export interface ReporterClass<TOptions extends Record<string, unknown> = Record<string, unknown>> {
55
+ new (options?: TOptions, context?: ReporterContext): Reporter;
56
+ }
57
+ /**
58
+ * Context provided to reporter plugins
59
+ *
60
+ * Contains version information and utility functions that plugins can use.
61
+ */
62
+ export interface ReporterContext {
63
+ /**
64
+ * Logger for reporter output
65
+ *
66
+ * Use this instead of console.log/console.error to ensure output respects the
67
+ * user's verbosity settings and uses the correct output streams.
68
+ */
69
+ readonly logger: Logger;
70
+ /**
71
+ * Plugin API version
72
+ *
73
+ * Incremented when breaking changes are made to the plugin API. Currently
74
+ * version 1.
75
+ */
76
+ readonly pluginApiVersion: number;
77
+ /**
78
+ * Utility functions for formatting benchmark data
79
+ */
80
+ readonly utils: ReporterUtils;
81
+ /**
82
+ * ModestBench version
83
+ *
84
+ * Plugins can use this to check compatibility.
85
+ */
86
+ readonly version: string;
87
+ }
88
+ /**
89
+ * Factory function for creating reporter instances
90
+ *
91
+ * Plugin authors can export a default function matching this signature. The
92
+ * function receives options from the config file and a context object with
93
+ * utilities. Use the generic parameter to define the shape of your options.
94
+ *
95
+ * @example
96
+ *
97
+ * ```typescript
98
+ * import type { ReporterFactory } from 'modestbench';
99
+ *
100
+ * interface MyReporterOptions {
101
+ * verbose?: boolean;
102
+ * outputFormat?: 'text' | 'markdown';
103
+ * }
104
+ *
105
+ * const createReporter: ReporterFactory<MyReporterOptions> = (
106
+ * options,
107
+ * context,
108
+ * ) => {
109
+ * return {
110
+ * onStart(run) {
111
+ * if (options.verbose) console.log('Starting');
112
+ * },
113
+ * onEnd(run) {
114
+ * console.log('Done');
115
+ * },
116
+ * onError(error) {
117
+ * console.error(error);
118
+ * },
119
+ * onTaskResult(result) {
120
+ * console.log(
121
+ * `${result.name}: ${context.utils.formatDuration(result.mean)}`,
122
+ * );
123
+ * },
124
+ * };
125
+ * };
126
+ *
127
+ * export default createReporter;
128
+ * ```
129
+ *
130
+ * @typeParam TOptions - The shape of the options object (defaults to
131
+ * Record<string, unknown>)
132
+ */
133
+ export type ReporterFactory<TOptions extends Record<string, unknown> = Record<string, unknown>> = (options: TOptions, context: ReporterContext) => Promise<Reporter> | Reporter;
134
+ /**
135
+ * Union type representing all valid reporter plugin exports
136
+ *
137
+ * A reporter plugin module can export:
138
+ *
139
+ * - A plain Reporter object (simplest form, no options)
140
+ * - A ReporterClass constructor (instantiated with options)
141
+ * - A ReporterFactory function (most flexible, supports async)
142
+ */
143
+ export type ReporterPlugin = Reporter | ReporterClass | ReporterFactory;
144
+ /**
145
+ * Utility functions available to reporter plugins
146
+ *
147
+ * These functions help format benchmark data consistently.
148
+ */
149
+ export interface ReporterUtils {
150
+ /**
151
+ * Format bytes in human-readable format
152
+ *
153
+ * @param bytes - Number of bytes
154
+ * @returns Formatted string (e.g., "1.5 GB", "256 MB")
155
+ */
156
+ formatBytes(bytes: number): string;
157
+ /**
158
+ * Format duration in human-readable format
159
+ *
160
+ * @param nanoseconds - Duration in nanoseconds
161
+ * @returns Formatted string (e.g., "1.23ms", "456.78μs")
162
+ */
163
+ formatDuration(nanoseconds: number): string;
164
+ /**
165
+ * Format operations per second
166
+ *
167
+ * @param opsPerSecond - Operations per second
168
+ * @returns Formatted string (e.g., "1.2M ops/sec", "456K ops/sec")
169
+ */
170
+ formatOpsPerSecond(opsPerSecond: number): string;
171
+ /**
172
+ * Format percentage value
173
+ *
174
+ * @param value - Percentage value
175
+ * @returns Formatted string (e.g., "12.34%")
176
+ */
177
+ formatPercentage(value: number): string;
178
+ }
179
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAwB;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,sBAAqB;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,WAAW,aAAa,CAC5B,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAElE,KAAK,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,QAAQ,CAAC;CAC/D;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,MAAM,eAAe,CACzB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAChE,CACF,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,eAAe,KACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AAElC;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,aAAa,GAAG,eAAe,CAAC;AAExE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEnC;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAE5C;;;;;OAKG;IACH,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;IAEjD;;;;;OAKG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACzC"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * ModestBench Plugin Types
3
+ *
4
+ * Type definitions for third-party reporter plugins. These types are exported
5
+ * from the main package for use by plugin authors.
6
+ */
7
+ import type { Reporter } from "./interfaces.js";
8
+ import type { Logger } from "./utility.js";
9
+ /**
10
+ * Class constructor for reporter plugins
11
+ *
12
+ * Plugin authors can export a default class matching this signature. The class
13
+ * constructor receives options from the config file and a context object with
14
+ * utilities.
15
+ *
16
+ * @example
17
+ *
18
+ * ```typescript
19
+ * import type { Reporter, ReporterContext } from 'modestbench';
20
+ *
21
+ * interface MyReporterOptions {
22
+ * verbose?: boolean;
23
+ * outputFormat?: 'text' | 'markdown';
24
+ * }
25
+ *
26
+ * class MyReporter implements Reporter {
27
+ * constructor(
28
+ * private options: MyReporterOptions,
29
+ * private context: ReporterContext,
30
+ * ) {}
31
+ *
32
+ * onStart(run) {
33
+ * if (this.options.verbose) console.log('Starting');
34
+ * }
35
+ * onEnd(run) {
36
+ * console.log('Done');
37
+ * }
38
+ * onError(error) {
39
+ * console.error(error);
40
+ * }
41
+ * onTaskResult(result) {
42
+ * console.log(
43
+ * `${result.name}: ${this.context.utils.formatDuration(result.mean)}`,
44
+ * );
45
+ * }
46
+ * }
47
+ *
48
+ * export default MyReporter;
49
+ * ```
50
+ *
51
+ * @typeParam TOptions - The shape of the options object (defaults to
52
+ * Record<string, unknown>)
53
+ */
54
+ export interface ReporterClass<TOptions extends Record<string, unknown> = Record<string, unknown>> {
55
+ new (options?: TOptions, context?: ReporterContext): Reporter;
56
+ }
57
+ /**
58
+ * Context provided to reporter plugins
59
+ *
60
+ * Contains version information and utility functions that plugins can use.
61
+ */
62
+ export interface ReporterContext {
63
+ /**
64
+ * Logger for reporter output
65
+ *
66
+ * Use this instead of console.log/console.error to ensure output respects the
67
+ * user's verbosity settings and uses the correct output streams.
68
+ */
69
+ readonly logger: Logger;
70
+ /**
71
+ * Plugin API version
72
+ *
73
+ * Incremented when breaking changes are made to the plugin API. Currently
74
+ * version 1.
75
+ */
76
+ readonly pluginApiVersion: number;
77
+ /**
78
+ * Utility functions for formatting benchmark data
79
+ */
80
+ readonly utils: ReporterUtils;
81
+ /**
82
+ * ModestBench version
83
+ *
84
+ * Plugins can use this to check compatibility.
85
+ */
86
+ readonly version: string;
87
+ }
88
+ /**
89
+ * Factory function for creating reporter instances
90
+ *
91
+ * Plugin authors can export a default function matching this signature. The
92
+ * function receives options from the config file and a context object with
93
+ * utilities. Use the generic parameter to define the shape of your options.
94
+ *
95
+ * @example
96
+ *
97
+ * ```typescript
98
+ * import type { ReporterFactory } from 'modestbench';
99
+ *
100
+ * interface MyReporterOptions {
101
+ * verbose?: boolean;
102
+ * outputFormat?: 'text' | 'markdown';
103
+ * }
104
+ *
105
+ * const createReporter: ReporterFactory<MyReporterOptions> = (
106
+ * options,
107
+ * context,
108
+ * ) => {
109
+ * return {
110
+ * onStart(run) {
111
+ * if (options.verbose) console.log('Starting');
112
+ * },
113
+ * onEnd(run) {
114
+ * console.log('Done');
115
+ * },
116
+ * onError(error) {
117
+ * console.error(error);
118
+ * },
119
+ * onTaskResult(result) {
120
+ * console.log(
121
+ * `${result.name}: ${context.utils.formatDuration(result.mean)}`,
122
+ * );
123
+ * },
124
+ * };
125
+ * };
126
+ *
127
+ * export default createReporter;
128
+ * ```
129
+ *
130
+ * @typeParam TOptions - The shape of the options object (defaults to
131
+ * Record<string, unknown>)
132
+ */
133
+ export type ReporterFactory<TOptions extends Record<string, unknown> = Record<string, unknown>> = (options: TOptions, context: ReporterContext) => Promise<Reporter> | Reporter;
134
+ /**
135
+ * Union type representing all valid reporter plugin exports
136
+ *
137
+ * A reporter plugin module can export:
138
+ *
139
+ * - A plain Reporter object (simplest form, no options)
140
+ * - A ReporterClass constructor (instantiated with options)
141
+ * - A ReporterFactory function (most flexible, supports async)
142
+ */
143
+ export type ReporterPlugin = Reporter | ReporterClass | ReporterFactory;
144
+ /**
145
+ * Utility functions available to reporter plugins
146
+ *
147
+ * These functions help format benchmark data consistently.
148
+ */
149
+ export interface ReporterUtils {
150
+ /**
151
+ * Format bytes in human-readable format
152
+ *
153
+ * @param bytes - Number of bytes
154
+ * @returns Formatted string (e.g., "1.5 GB", "256 MB")
155
+ */
156
+ formatBytes(bytes: number): string;
157
+ /**
158
+ * Format duration in human-readable format
159
+ *
160
+ * @param nanoseconds - Duration in nanoseconds
161
+ * @returns Formatted string (e.g., "1.23ms", "456.78μs")
162
+ */
163
+ formatDuration(nanoseconds: number): string;
164
+ /**
165
+ * Format operations per second
166
+ *
167
+ * @param opsPerSecond - Operations per second
168
+ * @returns Formatted string (e.g., "1.2M ops/sec", "456K ops/sec")
169
+ */
170
+ formatOpsPerSecond(opsPerSecond: number): string;
171
+ /**
172
+ * Format percentage value
173
+ *
174
+ * @param value - Percentage value
175
+ * @returns Formatted string (e.g., "12.34%")
176
+ */
177
+ formatPercentage(value: number): string;
178
+ }
179
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAqB;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,WAAW,aAAa,CAC5B,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAElE,KAAK,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,QAAQ,CAAC;CAC/D;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,MAAM,eAAe,CACzB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAChE,CACF,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,eAAe,KACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AAElC;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,aAAa,GAAG,eAAe,CAAC;AAExE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEnC;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAE5C;;;;;OAKG;IACH,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;IAEjD;;;;;OAKG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACzC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * ModestBench Plugin Types
3
+ *
4
+ * Type definitions for third-party reporter plugins. These types are exported
5
+ * from the main package for use by plugin authors.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -6,13 +6,74 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
12
42
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.findPackageRoot = void 0;
43
+ exports.findPackageRoot = exports.getPackageVersion = void 0;
44
+ const node_fs_1 = require("node:fs");
14
45
  const promises_1 = require("node:fs/promises");
15
- const node_path_1 = __importDefault(require("node:path"));
46
+ const node_path_1 = __importStar(require("node:path"));
47
+ const node_url_1 = require("node:url");
48
+ /**
49
+ * Cached package version, loaded at module initialization
50
+ *
51
+ * NOTE: This relies on package.json being at the same relative path from both
52
+ * src/ and dist/ directories (../../package.json). If the build output
53
+ * structure changes, this will break.
54
+ */
55
+ const cachedPackageVersion = (() => {
56
+ try {
57
+ const __dirname = (0, node_path_1.dirname)((0, node_url_1.fileURLToPath)(require("url").pathToFileURL(__filename)));
58
+ const pkgPath = (0, node_path_1.join)(__dirname, '..', '..', 'package.json');
59
+ const pkgContent = (0, node_fs_1.readFileSync)(pkgPath, 'utf8');
60
+ const pkg = JSON.parse(pkgContent);
61
+ return pkg.version;
62
+ }
63
+ catch {
64
+ // Fallback if package.json cannot be read (shouldn't happen in normal use)
65
+ return 'unknown';
66
+ }
67
+ })();
68
+ /**
69
+ * Get the ModestBench package version
70
+ *
71
+ * @returns The version string from package.json
72
+ */
73
+ const getPackageVersion = () => {
74
+ return cachedPackageVersion;
75
+ };
76
+ exports.getPackageVersion = getPackageVersion;
16
77
  /**
17
78
  * Find the nearest package.json and return its directory
18
79
  *
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/utils/package.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAEH,+CAA4C;AAC5C,0DAA6B;AAE7B;;;;;GAKG;AACI,MAAM,eAAe,GAAG,KAAK,EAAE,QAAgB,EAAmB,EAAE;IACzE,IAAI,UAAU,GAAG,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,mBAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;IAEzC,OAAO,UAAU,KAAK,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;YAC1D,MAAM,IAAA,mBAAQ,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACrC,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;YAC9C,UAAU,GAAG,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,mDAAmD;IACnD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAjBW,QAAA,eAAe,mBAiB1B"}
1
+ {"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/utils/package.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qCAAuC;AACvC,+CAA4C;AAC5C,uDAAgD;AAChD,uCAAyC;AAEzC;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE;IACjC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAA,mBAAO,EAAC,IAAA,wBAAa,2CAAiB,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,IAAA,sBAAY,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAwB,CAAC;QAC1D,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,2EAA2E;QAC3E,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AAEL;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,GAAW,EAAE;IAC5C,OAAO,oBAAoB,CAAC;AAC9B,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEF;;;;;GAKG;AACI,MAAM,eAAe,GAAG,KAAK,EAAE,QAAgB,EAAmB,EAAE;IACzE,IAAI,UAAU,GAAG,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,mBAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;IAEzC,OAAO,UAAU,KAAK,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;YAC1D,MAAM,IAAA,mBAAQ,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACrC,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;YAC9C,UAAU,GAAG,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,mDAAmD;IACnD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAjBW,QAAA,eAAe,mBAiB1B"}
@@ -5,6 +5,12 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
+ /**
9
+ * Get the ModestBench package version
10
+ *
11
+ * @returns The version string from package.json
12
+ */
13
+ export declare const getPackageVersion: () => string;
8
14
  /**
9
15
  * Find the nearest package.json and return its directory
10
16
  *
@@ -1 +1 @@
1
- {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/utils/package.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,CAiBtE,CAAC"}
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/utils/package.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2BH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAO,MAEpC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,CAiBtE,CAAC"}
@@ -5,6 +5,12 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
+ /**
9
+ * Get the ModestBench package version
10
+ *
11
+ * @returns The version string from package.json
12
+ */
13
+ export declare const getPackageVersion: () => string;
8
14
  /**
9
15
  * Find the nearest package.json and return its directory
10
16
  *
@@ -1 +1 @@
1
- {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/utils/package.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,CAiBtE,CAAC"}
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/utils/package.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2BH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAO,MAEpC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,CAiBtE,CAAC"}
@@ -5,8 +5,38 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
+ import { readFileSync } from 'node:fs';
8
9
  import { readFile } from 'node:fs/promises';
9
- import path from 'node:path';
10
+ import path, { dirname, join } from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+ /**
13
+ * Cached package version, loaded at module initialization
14
+ *
15
+ * NOTE: This relies on package.json being at the same relative path from both
16
+ * src/ and dist/ directories (../../package.json). If the build output
17
+ * structure changes, this will break.
18
+ */
19
+ const cachedPackageVersion = (() => {
20
+ try {
21
+ const __dirname = dirname(fileURLToPath(import.meta.url));
22
+ const pkgPath = join(__dirname, '..', '..', 'package.json');
23
+ const pkgContent = readFileSync(pkgPath, 'utf8');
24
+ const pkg = JSON.parse(pkgContent);
25
+ return pkg.version;
26
+ }
27
+ catch {
28
+ // Fallback if package.json cannot be read (shouldn't happen in normal use)
29
+ return 'unknown';
30
+ }
31
+ })();
32
+ /**
33
+ * Get the ModestBench package version
34
+ *
35
+ * @returns The version string from package.json
36
+ */
37
+ export const getPackageVersion = () => {
38
+ return cachedPackageVersion;
39
+ };
10
40
  /**
11
41
  * Find the nearest package.json and return its directory
12
42
  *
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/utils/package.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,QAAgB,EAAmB,EAAE;IACzE,IAAI,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;IAEzC,OAAO,UAAU,KAAK,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;YAC1D,MAAM,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACrC,OAAO,UAAU,CAAC;QACpB,CAAC;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