modestbench 0.0.3 → 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 +26 -0
- package/README.md +39 -31
- package/dist/bootstrap.cjs +10 -12
- package/dist/bootstrap.cjs.map +1 -1
- package/dist/bootstrap.d.cts.map +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +5 -7
- package/dist/bootstrap.js.map +1 -1
- package/dist/cli/commands/history.cjs +108 -265
- package/dist/cli/commands/history.cjs.map +1 -1
- package/dist/cli/commands/history.d.cts +75 -12
- package/dist/cli/commands/history.d.cts.map +1 -1
- package/dist/cli/commands/history.d.ts +75 -12
- package/dist/cli/commands/history.d.ts.map +1 -1
- package/dist/cli/commands/history.js +105 -267
- package/dist/cli/commands/history.js.map +1 -1
- package/dist/cli/commands/init.cjs +5 -4
- package/dist/cli/commands/init.cjs.map +1 -1
- package/dist/cli/commands/init.d.cts.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +5 -4
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/run.cjs +32 -9
- package/dist/cli/commands/run.cjs.map +1 -1
- package/dist/cli/commands/run.d.cts +1 -0
- package/dist/cli/commands/run.d.cts.map +1 -1
- package/dist/cli/commands/run.d.ts +1 -0
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +32 -9
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/index.cjs +336 -103
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +1 -2
- package/dist/cli/index.d.cts.map +1 -1
- package/dist/cli/index.d.ts +1 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +332 -99
- package/dist/cli/index.js.map +1 -1
- package/dist/constants.cjs +53 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +36 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts +36 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +52 -0
- package/dist/constants.js.map +1 -1
- package/dist/core/engine.cjs +23 -43
- package/dist/core/engine.cjs.map +1 -1
- package/dist/core/engine.d.cts +4 -3
- package/dist/core/engine.d.cts.map +1 -1
- package/dist/core/engine.d.ts +4 -3
- package/dist/core/engine.d.ts.map +1 -1
- package/dist/core/engine.js +23 -43
- package/dist/core/engine.js.map +1 -1
- package/dist/core/engines/accurate-engine.cjs +2 -1
- package/dist/core/engines/accurate-engine.cjs.map +1 -1
- package/dist/core/engines/accurate-engine.d.cts.map +1 -1
- package/dist/core/engines/accurate-engine.d.ts.map +1 -1
- package/dist/core/engines/accurate-engine.js +2 -1
- package/dist/core/engines/accurate-engine.js.map +1 -1
- package/dist/core/engines/tinybench-engine.cjs +6 -5
- package/dist/core/engines/tinybench-engine.cjs.map +1 -1
- package/dist/core/engines/tinybench-engine.d.cts.map +1 -1
- package/dist/core/engines/tinybench-engine.d.ts.map +1 -1
- package/dist/core/engines/tinybench-engine.js +6 -5
- package/dist/core/engines/tinybench-engine.js.map +1 -1
- package/dist/core/output-path-resolver.cjs +34 -0
- package/dist/core/output-path-resolver.cjs.map +1 -0
- package/dist/core/output-path-resolver.d.cts +10 -0
- package/dist/core/output-path-resolver.d.cts.map +1 -0
- package/dist/core/output-path-resolver.d.ts +10 -0
- package/dist/core/output-path-resolver.d.ts.map +1 -0
- package/dist/core/output-path-resolver.js +30 -0
- package/dist/core/output-path-resolver.js.map +1 -0
- package/dist/errors/base.cjs +130 -0
- package/dist/errors/base.cjs.map +1 -0
- package/dist/errors/base.d.cts +97 -0
- package/dist/errors/base.d.cts.map +1 -0
- package/dist/errors/base.d.ts +97 -0
- package/dist/errors/base.d.ts.map +1 -0
- package/dist/errors/base.js +124 -0
- package/dist/errors/base.js.map +1 -0
- package/dist/errors/cli.cjs +58 -0
- package/dist/errors/cli.cjs.map +1 -0
- package/dist/errors/cli.d.cts +44 -0
- package/dist/errors/cli.d.cts.map +1 -0
- package/dist/errors/cli.d.ts +44 -0
- package/dist/errors/cli.d.ts.map +1 -0
- package/dist/errors/cli.js +52 -0
- package/dist/errors/cli.js.map +1 -0
- package/dist/errors/configuration.cjs +48 -0
- package/dist/errors/configuration.cjs.map +1 -0
- package/dist/errors/configuration.d.cts +41 -0
- package/dist/errors/configuration.d.cts.map +1 -0
- package/dist/errors/configuration.d.ts +41 -0
- package/dist/errors/configuration.d.ts.map +1 -0
- package/dist/errors/configuration.js +41 -0
- package/dist/errors/configuration.js.map +1 -0
- package/dist/errors/execution.cjs +65 -0
- package/dist/errors/execution.cjs.map +1 -0
- package/dist/errors/execution.d.cts +56 -0
- package/dist/errors/execution.d.cts.map +1 -0
- package/dist/errors/execution.d.ts +56 -0
- package/dist/errors/execution.d.ts.map +1 -0
- package/dist/errors/execution.js +56 -0
- package/dist/errors/execution.js.map +1 -0
- package/dist/errors/file.cjs +56 -0
- package/dist/errors/file.cjs.map +1 -0
- package/dist/errors/file.d.cts +48 -0
- package/dist/errors/file.d.cts.map +1 -0
- package/dist/errors/file.d.ts +48 -0
- package/dist/errors/file.d.ts.map +1 -0
- package/dist/errors/file.js +48 -0
- package/dist/errors/file.js.map +1 -0
- package/dist/errors/index.cjs +59 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +16 -0
- package/dist/errors/index.d.cts.map +1 -0
- package/dist/errors/index.d.ts +16 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +24 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/reporter.cjs +38 -0
- package/dist/errors/reporter.cjs.map +1 -0
- package/dist/errors/reporter.d.cts +32 -0
- package/dist/errors/reporter.d.cts.map +1 -0
- package/dist/errors/reporter.d.ts +32 -0
- package/dist/errors/reporter.d.ts.map +1 -0
- package/dist/errors/reporter.js +32 -0
- package/dist/errors/reporter.js.map +1 -0
- package/dist/errors/storage.cjs +55 -0
- package/dist/errors/storage.cjs.map +1 -0
- package/dist/errors/storage.d.cts +47 -0
- package/dist/errors/storage.d.cts.map +1 -0
- package/dist/errors/storage.d.ts +47 -0
- package/dist/errors/storage.d.ts.map +1 -0
- package/dist/errors/storage.js +47 -0
- package/dist/errors/storage.js.map +1 -0
- package/dist/errors/validation.cjs +38 -0
- package/dist/errors/validation.cjs.map +1 -0
- package/dist/errors/validation.d.cts +32 -0
- package/dist/errors/validation.d.cts.map +1 -0
- package/dist/errors/validation.d.ts +32 -0
- package/dist/errors/validation.d.ts.map +1 -0
- package/dist/errors/validation.js +32 -0
- package/dist/errors/validation.js.map +1 -0
- package/dist/formatters/history/base.cjs +9 -0
- package/dist/formatters/history/base.cjs.map +1 -0
- package/dist/formatters/history/base.d.cts +26 -0
- package/dist/formatters/history/base.d.cts.map +1 -0
- package/dist/formatters/history/base.d.ts +26 -0
- package/dist/formatters/history/base.d.ts.map +1 -0
- package/dist/formatters/history/base.js +8 -0
- package/dist/formatters/history/base.js.map +1 -0
- package/dist/formatters/history/compare.cjs +127 -0
- package/dist/formatters/history/compare.cjs.map +1 -0
- package/dist/formatters/history/compare.d.cts +21 -0
- package/dist/formatters/history/compare.d.cts.map +1 -0
- package/dist/formatters/history/compare.d.ts +21 -0
- package/dist/formatters/history/compare.d.ts.map +1 -0
- package/dist/formatters/history/compare.js +123 -0
- package/dist/formatters/history/compare.js.map +1 -0
- package/dist/formatters/history/list.cjs +74 -0
- package/dist/formatters/history/list.cjs.map +1 -0
- package/dist/formatters/history/list.d.cts +25 -0
- package/dist/formatters/history/list.d.cts.map +1 -0
- package/dist/formatters/history/list.d.ts +25 -0
- package/dist/formatters/history/list.d.ts.map +1 -0
- package/dist/formatters/history/list.js +70 -0
- package/dist/formatters/history/list.js.map +1 -0
- package/dist/formatters/history/show.cjs +98 -0
- package/dist/formatters/history/show.cjs.map +1 -0
- package/dist/formatters/history/show.d.cts +21 -0
- package/dist/formatters/history/show.d.cts.map +1 -0
- package/dist/formatters/history/show.d.ts +21 -0
- package/dist/formatters/history/show.d.ts.map +1 -0
- package/dist/formatters/history/show.js +94 -0
- package/dist/formatters/history/show.js.map +1 -0
- package/dist/formatters/history/trends.cjs +194 -0
- package/dist/formatters/history/trends.cjs.map +1 -0
- package/dist/formatters/history/trends.d.cts +22 -0
- package/dist/formatters/history/trends.d.cts.map +1 -0
- package/dist/formatters/history/trends.d.ts +22 -0
- package/dist/formatters/history/trends.d.ts.map +1 -0
- package/dist/formatters/history/trends.js +190 -0
- package/dist/formatters/history/trends.js.map +1 -0
- package/dist/formatters/history/visualization.cjs +79 -0
- package/dist/formatters/history/visualization.cjs.map +1 -0
- package/dist/formatters/history/visualization.d.cts +24 -0
- package/dist/formatters/history/visualization.d.cts.map +1 -0
- package/dist/formatters/history/visualization.d.ts +24 -0
- package/dist/formatters/history/visualization.d.ts.map +1 -0
- package/dist/formatters/history/visualization.js +74 -0
- package/dist/formatters/history/visualization.js.map +1 -0
- package/dist/index.cjs +17 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -11
- package/dist/index.js.map +1 -1
- package/dist/reporters/csv.cjs +5 -4
- package/dist/reporters/csv.cjs.map +1 -1
- package/dist/reporters/csv.d.cts +1 -1
- package/dist/reporters/csv.d.cts.map +1 -1
- package/dist/reporters/csv.d.ts +1 -1
- package/dist/reporters/csv.d.ts.map +1 -1
- package/dist/reporters/csv.js +4 -3
- package/dist/reporters/csv.js.map +1 -1
- package/dist/reporters/human.cjs +24 -62
- package/dist/reporters/human.cjs.map +1 -1
- package/dist/reporters/human.d.cts +1 -1
- package/dist/reporters/human.d.cts.map +1 -1
- package/dist/reporters/human.d.ts +1 -1
- package/dist/reporters/human.d.ts.map +1 -1
- package/dist/reporters/human.js +3 -41
- package/dist/reporters/human.js.map +1 -1
- package/dist/reporters/json.cjs +5 -4
- package/dist/reporters/json.cjs.map +1 -1
- package/dist/reporters/json.d.cts +1 -1
- package/dist/reporters/json.d.cts.map +1 -1
- package/dist/reporters/json.d.ts +1 -1
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +4 -3
- package/dist/reporters/json.js.map +1 -1
- package/dist/reporters/simple.cjs +3 -3
- package/dist/reporters/simple.cjs.map +1 -1
- package/dist/reporters/simple.d.cts +1 -1
- package/dist/reporters/simple.d.cts.map +1 -1
- package/dist/reporters/simple.d.ts +1 -1
- package/dist/reporters/simple.d.ts.map +1 -1
- package/dist/reporters/simple.js +2 -2
- package/dist/reporters/simple.js.map +1 -1
- package/dist/{config/manager.cjs → services/config-manager.cjs} +10 -4
- package/dist/services/config-manager.cjs.map +1 -0
- package/dist/{config/manager.d.cts → services/config-manager.d.cts} +1 -1
- package/dist/services/config-manager.d.cts.map +1 -0
- package/dist/{config/manager.d.ts → services/config-manager.d.ts} +1 -1
- package/dist/services/config-manager.d.ts.map +1 -0
- package/dist/{config/manager.js → services/config-manager.js} +10 -4
- package/dist/services/config-manager.js.map +1 -0
- package/dist/{core/loader.cjs → services/file-loader.cjs} +18 -7
- package/dist/services/file-loader.cjs.map +1 -0
- package/dist/{core/loader.d.cts → services/file-loader.d.cts} +1 -1
- package/dist/services/file-loader.d.cts.map +1 -0
- package/dist/{core/loader.d.ts → services/file-loader.d.ts} +1 -1
- package/dist/services/file-loader.d.ts.map +1 -0
- package/dist/{core/loader.js → services/file-loader.js} +18 -7
- package/dist/services/file-loader.js.map +1 -0
- package/dist/services/history/comparison.cjs +124 -0
- package/dist/services/history/comparison.cjs.map +1 -0
- package/dist/services/history/comparison.d.cts +18 -0
- package/dist/services/history/comparison.d.cts.map +1 -0
- package/dist/services/history/comparison.d.ts +18 -0
- package/dist/services/history/comparison.d.ts.map +1 -0
- package/dist/services/history/comparison.js +120 -0
- package/dist/services/history/comparison.js.map +1 -0
- package/dist/services/history/models.cjs +9 -0
- package/dist/services/history/models.cjs.map +1 -0
- package/dist/services/history/models.d.cts +139 -0
- package/dist/services/history/models.d.cts.map +1 -0
- package/dist/services/history/models.d.ts +139 -0
- package/dist/services/history/models.d.ts.map +1 -0
- package/dist/services/history/models.js +8 -0
- package/dist/services/history/models.js.map +1 -0
- package/dist/services/history/query.cjs +97 -0
- package/dist/services/history/query.cjs.map +1 -0
- package/dist/services/history/query.d.cts +38 -0
- package/dist/services/history/query.d.cts.map +1 -0
- package/dist/services/history/query.d.ts +38 -0
- package/dist/services/history/query.d.ts.map +1 -0
- package/dist/services/history/query.js +92 -0
- package/dist/services/history/query.js.map +1 -0
- package/dist/services/history/trend-analysis.cjs +187 -0
- package/dist/services/history/trend-analysis.cjs.map +1 -0
- package/dist/services/history/trend-analysis.d.cts +34 -0
- package/dist/services/history/trend-analysis.d.cts.map +1 -0
- package/dist/services/history/trend-analysis.d.ts +34 -0
- package/dist/services/history/trend-analysis.d.ts.map +1 -0
- package/dist/services/history/trend-analysis.js +179 -0
- package/dist/services/history/trend-analysis.js.map +1 -0
- package/dist/{storage/history.cjs → services/history-storage.cjs} +33 -12
- package/dist/services/history-storage.cjs.map +1 -0
- package/dist/{storage/history.d.cts → services/history-storage.d.cts} +1 -1
- package/dist/services/history-storage.d.cts.map +1 -0
- package/dist/{storage/history.d.ts → services/history-storage.d.ts} +1 -1
- package/dist/services/history-storage.d.ts.map +1 -0
- package/dist/{storage/history.js → services/history-storage.js} +33 -12
- package/dist/services/history-storage.js.map +1 -0
- package/dist/{progress/manager.cjs → services/progress-manager.cjs} +1 -1
- package/dist/services/progress-manager.cjs.map +1 -0
- package/dist/{progress/manager.d.cts → services/progress-manager.d.cts} +1 -1
- package/dist/services/progress-manager.d.cts.map +1 -0
- package/dist/{progress/manager.d.ts → services/progress-manager.d.ts} +1 -1
- package/dist/services/progress-manager.d.ts.map +1 -0
- package/dist/{progress/manager.js → services/progress-manager.js} +1 -1
- package/dist/services/progress-manager.js.map +1 -0
- package/dist/{reporters/registry.cjs → services/reporter-registry.cjs} +4 -3
- package/dist/services/reporter-registry.cjs.map +1 -0
- package/dist/{reporters/registry.d.cts → services/reporter-registry.d.cts} +1 -1
- package/dist/services/reporter-registry.d.cts.map +1 -0
- package/dist/{reporters/registry.d.ts → services/reporter-registry.d.ts} +1 -1
- package/dist/services/reporter-registry.d.ts.map +1 -0
- package/dist/{reporters/registry.js → services/reporter-registry.js} +4 -3
- package/dist/services/reporter-registry.js.map +1 -0
- package/dist/types/cli.d.cts +3 -0
- package/dist/types/cli.d.cts.map +1 -1
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/interfaces.d.cts +1 -34
- package/dist/types/interfaces.d.cts.map +1 -1
- package/dist/types/interfaces.d.ts +1 -34
- package/dist/types/interfaces.d.ts.map +1 -1
- package/dist/utils/ansi.cjs +61 -0
- package/dist/utils/ansi.cjs.map +1 -0
- package/dist/utils/ansi.d.cts +53 -0
- package/dist/utils/ansi.d.cts.map +1 -0
- package/dist/utils/ansi.d.ts +53 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +57 -0
- package/dist/utils/ansi.js.map +1 -0
- package/package.json +10 -8
- package/src/bootstrap.ts +5 -7
- package/src/cli/commands/history.ts +195 -341
- package/src/cli/commands/init.ts +14 -4
- package/src/cli/commands/run.ts +52 -7
- package/src/cli/index.ts +393 -119
- package/src/constants.ts +60 -0
- package/src/core/engine.ts +40 -48
- package/src/core/engines/accurate-engine.ts +4 -1
- package/src/core/engines/tinybench-engine.ts +12 -5
- package/src/core/output-path-resolver.ts +38 -0
- package/src/errors/base.ts +152 -0
- package/src/errors/cli.ts +59 -0
- package/src/errors/configuration.ts +45 -0
- package/src/errors/execution.ts +62 -0
- package/src/errors/file.ts +53 -0
- package/src/errors/index.ts +71 -0
- package/src/errors/reporter.ts +35 -0
- package/src/errors/storage.ts +52 -0
- package/src/errors/validation.ts +35 -0
- package/src/formatters/history/base.ts +28 -0
- package/src/formatters/history/compare.ts +186 -0
- package/src/formatters/history/list.ts +101 -0
- package/src/formatters/history/show.ts +155 -0
- package/src/formatters/history/trends.ts +281 -0
- package/src/formatters/history/visualization.ts +93 -0
- package/src/index.ts +10 -14
- package/src/reporters/csv.ts +5 -3
- package/src/reporters/human.ts +3 -43
- package/src/reporters/json.ts +5 -3
- package/src/reporters/simple.ts +2 -2
- package/src/{config/manager.ts → services/config-manager.ts} +13 -3
- package/src/{core/loader.ts → services/file-loader.ts} +28 -6
- package/src/services/history/comparison.ts +130 -0
- package/src/services/history/models.ts +148 -0
- package/src/services/history/query.ts +116 -0
- package/src/services/history/trend-analysis.ts +238 -0
- package/src/{storage/history.ts → services/history-storage.ts} +58 -11
- package/src/{reporters/registry.ts → services/reporter-registry.ts} +9 -2
- package/src/types/cli.ts +3 -0
- package/src/types/interfaces.ts +0 -43
- package/src/utils/ansi.ts +59 -0
- package/dist/config/manager.cjs.map +0 -1
- package/dist/config/manager.d.cts.map +0 -1
- package/dist/config/manager.d.ts.map +0 -1
- package/dist/config/manager.js.map +0 -1
- package/dist/core/error-manager.cjs +0 -303
- package/dist/core/error-manager.cjs.map +0 -1
- package/dist/core/error-manager.d.cts +0 -77
- package/dist/core/error-manager.d.cts.map +0 -1
- package/dist/core/error-manager.d.ts +0 -77
- package/dist/core/error-manager.d.ts.map +0 -1
- package/dist/core/error-manager.js +0 -299
- package/dist/core/error-manager.js.map +0 -1
- package/dist/core/loader.cjs.map +0 -1
- package/dist/core/loader.d.cts.map +0 -1
- package/dist/core/loader.d.ts.map +0 -1
- package/dist/core/loader.js.map +0 -1
- package/dist/progress/manager.cjs.map +0 -1
- package/dist/progress/manager.d.cts.map +0 -1
- package/dist/progress/manager.d.ts.map +0 -1
- package/dist/progress/manager.js.map +0 -1
- package/dist/reporters/registry.cjs.map +0 -1
- package/dist/reporters/registry.d.cts.map +0 -1
- package/dist/reporters/registry.d.ts.map +0 -1
- package/dist/reporters/registry.js.map +0 -1
- package/dist/storage/history.cjs.map +0 -1
- package/dist/storage/history.d.cts.map +0 -1
- package/dist/storage/history.d.ts.map +0 -1
- package/dist/storage/history.js.map +0 -1
- package/src/core/error-manager.ts +0 -372
- /package/src/{progress/manager.ts → services/progress-manager.ts} +0 -0
package/src/core/engine.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* architecture.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { randomBytes } from 'node:crypto';
|
|
10
|
+
|
|
9
11
|
import type {
|
|
10
12
|
BenchmarkDefinition,
|
|
11
13
|
BenchmarkEngine,
|
|
@@ -15,8 +17,6 @@ import type {
|
|
|
15
17
|
CiInfo,
|
|
16
18
|
ConfigurationManager,
|
|
17
19
|
EnvironmentInfo,
|
|
18
|
-
ErrorManager,
|
|
19
|
-
ExecutionPhase,
|
|
20
20
|
FileLoader,
|
|
21
21
|
FileResult,
|
|
22
22
|
GitInfo,
|
|
@@ -33,12 +33,19 @@ import type {
|
|
|
33
33
|
ValidationWarning,
|
|
34
34
|
} from '../types/index.js';
|
|
35
35
|
|
|
36
|
+
import {
|
|
37
|
+
BenchmarkExecutionError,
|
|
38
|
+
FileDiscoveryError,
|
|
39
|
+
SchemaValidationError,
|
|
40
|
+
SetupError,
|
|
41
|
+
StructureValidationError,
|
|
42
|
+
} from '../errors/index.js';
|
|
43
|
+
|
|
36
44
|
/**
|
|
37
45
|
* Dependencies required by the BenchmarkEngine
|
|
38
46
|
*/
|
|
39
47
|
interface EngineDependencies {
|
|
40
48
|
readonly configManager: ConfigurationManager;
|
|
41
|
-
readonly errorManager: ErrorManager;
|
|
42
49
|
readonly fileLoader: FileLoader;
|
|
43
50
|
readonly historyStorage: HistoryStorage;
|
|
44
51
|
readonly progressManager: ProgressManager;
|
|
@@ -55,8 +62,6 @@ interface EngineDependencies {
|
|
|
55
62
|
export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
56
63
|
public readonly configManager: ConfigurationManager;
|
|
57
64
|
|
|
58
|
-
public readonly errorManager: ErrorManager;
|
|
59
|
-
|
|
60
65
|
public readonly fileLoader: FileLoader;
|
|
61
66
|
|
|
62
67
|
public readonly historyStorage: HistoryStorage;
|
|
@@ -71,7 +76,6 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
71
76
|
this.reporterRegistry = dependencies.reporterRegistry;
|
|
72
77
|
this.historyStorage = dependencies.historyStorage;
|
|
73
78
|
this.progressManager = dependencies.progressManager;
|
|
74
|
-
this.errorManager = dependencies.errorManager;
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
/**
|
|
@@ -86,13 +90,10 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
86
90
|
} catch (error) {
|
|
87
91
|
const discoveryError =
|
|
88
92
|
error instanceof Error ? error : new Error(String(error));
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
throw new Error(`File discovery failed: ${discoveryError.message}`);
|
|
93
|
+
throw new FileDiscoveryError(
|
|
94
|
+
`File discovery failed: ${discoveryError.message}`,
|
|
95
|
+
{ cause: discoveryError },
|
|
96
|
+
);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
@@ -105,11 +106,9 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
105
106
|
signal?: AbortSignal,
|
|
106
107
|
): Promise<BenchmarkRun> {
|
|
107
108
|
const startTime = new Date();
|
|
108
|
-
let currentPhase: ExecutionPhase = 'discovery';
|
|
109
109
|
|
|
110
110
|
try {
|
|
111
111
|
// 1. Merge configuration with defaults
|
|
112
|
-
currentPhase = 'discovery';
|
|
113
112
|
const mergedConfig = await this.configManager.load(
|
|
114
113
|
undefined, // No specific config path for now
|
|
115
114
|
config as Record<string, unknown>,
|
|
@@ -125,30 +124,18 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
125
124
|
if (mergedConfig.exclude?.length) {
|
|
126
125
|
msg += ` and excluding "${mergedConfig.exclude.join(', ')}"`;
|
|
127
126
|
}
|
|
128
|
-
|
|
129
|
-
this.errorManager.handleError(error, {
|
|
130
|
-
phase: currentPhase,
|
|
131
|
-
timestamp: new Date(),
|
|
132
|
-
});
|
|
133
|
-
throw error;
|
|
127
|
+
throw new FileDiscoveryError(msg);
|
|
134
128
|
}
|
|
135
129
|
|
|
136
130
|
// 3. Validate files
|
|
137
|
-
currentPhase = 'validation';
|
|
138
131
|
const validationResult = await this.validate(files);
|
|
139
132
|
if (!validationResult.valid) {
|
|
140
|
-
|
|
133
|
+
throw new SchemaValidationError(
|
|
141
134
|
`Validation failed: ${validationResult.errors.map((e) => e.message).join(', ')}`,
|
|
142
135
|
);
|
|
143
|
-
this.errorManager.handleError(error, {
|
|
144
|
-
phase: currentPhase,
|
|
145
|
-
timestamp: new Date(),
|
|
146
|
-
});
|
|
147
|
-
throw error;
|
|
148
136
|
}
|
|
149
137
|
|
|
150
138
|
// 4. Initialize progress tracking
|
|
151
|
-
currentPhase = 'setup';
|
|
152
139
|
const runId = this.generateRunId();
|
|
153
140
|
|
|
154
141
|
// Pre-calculate total tasks for progress tracking
|
|
@@ -236,7 +223,6 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
236
223
|
await this.callReporters(reporters, 'onStart', initialRun);
|
|
237
224
|
|
|
238
225
|
// 6. Execute benchmark files
|
|
239
|
-
currentPhase = 'execution';
|
|
240
226
|
const fileResults: FileResult[] = [];
|
|
241
227
|
|
|
242
228
|
for (const filePath of files) {
|
|
@@ -263,11 +249,6 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
263
249
|
} catch (error) {
|
|
264
250
|
const fileError =
|
|
265
251
|
error instanceof Error ? error : new Error(String(error));
|
|
266
|
-
this.errorManager.handleError(fileError, {
|
|
267
|
-
file: filePath,
|
|
268
|
-
phase: currentPhase,
|
|
269
|
-
timestamp: new Date(),
|
|
270
|
-
});
|
|
271
252
|
|
|
272
253
|
// Call reporter onError
|
|
273
254
|
await this.callReporters(reporters, 'onError', fileError);
|
|
@@ -350,15 +331,23 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
350
331
|
// 9. Return completed run
|
|
351
332
|
return finalRun;
|
|
352
333
|
} catch (error) {
|
|
334
|
+
// Re-throw our custom errors
|
|
335
|
+
if (
|
|
336
|
+
error instanceof FileDiscoveryError ||
|
|
337
|
+
error instanceof SchemaValidationError ||
|
|
338
|
+
error instanceof BenchmarkExecutionError
|
|
339
|
+
) {
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
|
|
353
343
|
const executionError =
|
|
354
344
|
error instanceof Error ? error : new Error(String(error));
|
|
355
|
-
const handledError = this.errorManager.handleError(executionError, {
|
|
356
|
-
phase: currentPhase,
|
|
357
|
-
timestamp: new Date(),
|
|
358
|
-
});
|
|
359
345
|
|
|
360
346
|
// Re-throw the original error with more context
|
|
361
|
-
throw new
|
|
347
|
+
throw new BenchmarkExecutionError(
|
|
348
|
+
`Benchmark execution failed: ${executionError.message}`,
|
|
349
|
+
{ cause: executionError },
|
|
350
|
+
);
|
|
362
351
|
}
|
|
363
352
|
}
|
|
364
353
|
|
|
@@ -423,11 +412,6 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
423
412
|
} catch (error) {
|
|
424
413
|
const validationError =
|
|
425
414
|
error instanceof Error ? error : new Error(String(error));
|
|
426
|
-
this.errorManager.handleError(validationError, {
|
|
427
|
-
file,
|
|
428
|
-
phase: 'validation',
|
|
429
|
-
timestamp: new Date(),
|
|
430
|
-
});
|
|
431
415
|
|
|
432
416
|
errors.push({
|
|
433
417
|
code: 'FILE_VALIDATION_ERROR',
|
|
@@ -516,7 +500,7 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
516
500
|
const benchmarkDef = benchmarkFile.exports as BenchmarkDefinition;
|
|
517
501
|
|
|
518
502
|
if (!benchmarkDef || typeof benchmarkDef !== 'object') {
|
|
519
|
-
throw new
|
|
503
|
+
throw new StructureValidationError(
|
|
520
504
|
'Benchmark file must export a default object with suites',
|
|
521
505
|
);
|
|
522
506
|
}
|
|
@@ -634,7 +618,9 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
634
618
|
error instanceof Error
|
|
635
619
|
? error
|
|
636
620
|
: new Error(`Setup failed: ${String(error)}`);
|
|
637
|
-
throw new
|
|
621
|
+
throw new SetupError(`Suite setup failed: ${setupError.message}`, {
|
|
622
|
+
cause: setupError,
|
|
623
|
+
});
|
|
638
624
|
}
|
|
639
625
|
}
|
|
640
626
|
|
|
@@ -713,9 +699,15 @@ export abstract class ModestBenchEngine implements BenchmarkEngine {
|
|
|
713
699
|
|
|
714
700
|
/**
|
|
715
701
|
* Generate a unique run ID
|
|
702
|
+
*
|
|
703
|
+
* Uses crypto.randomBytes for cryptographically random 7-character IDs.
|
|
704
|
+
* Format: 7 lowercase alphanumeric characters (e.g., "k3m9x2p")
|
|
716
705
|
*/
|
|
717
706
|
private generateRunId(): string {
|
|
718
|
-
|
|
707
|
+
// Generate random bytes, convert to hex, then to base36, take first 7 chars
|
|
708
|
+
const hex = randomBytes(4).toString('hex');
|
|
709
|
+
const num = parseInt(hex, 16);
|
|
710
|
+
return num.toString(36).padStart(7, '0').substring(0, 7);
|
|
719
711
|
}
|
|
720
712
|
|
|
721
713
|
/**
|
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
TaskResult,
|
|
27
27
|
} from '../../types/index.js';
|
|
28
28
|
|
|
29
|
+
import { StructureValidationError } from '../../errors/index.js';
|
|
29
30
|
import { ModestBenchEngine } from '../engine.js';
|
|
30
31
|
import { calculateStatistics, removeOutliersIQR } from '../stats-utils.js';
|
|
31
32
|
|
|
@@ -59,7 +60,9 @@ export class AccurateEngine extends ModestBenchEngine {
|
|
|
59
60
|
): Promise<TaskResult> {
|
|
60
61
|
try {
|
|
61
62
|
if (!taskData.fn || typeof taskData.fn !== 'function') {
|
|
62
|
-
throw new
|
|
63
|
+
throw new StructureValidationError(
|
|
64
|
+
'Benchmark task must have a "fn" function property',
|
|
65
|
+
);
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
// Check for V8 native syntax support
|
|
@@ -14,6 +14,11 @@ import type {
|
|
|
14
14
|
TaskResult,
|
|
15
15
|
} from '../../types/index.js';
|
|
16
16
|
|
|
17
|
+
import {
|
|
18
|
+
BenchmarkExecutionError,
|
|
19
|
+
OperationTooFastError,
|
|
20
|
+
StructureValidationError,
|
|
21
|
+
} from '../../errors/index.js';
|
|
17
22
|
import { ModestBenchEngine } from '../engine.js';
|
|
18
23
|
import { calculateStatistics, removeOutliersIQR } from '../stats-utils.js';
|
|
19
24
|
|
|
@@ -33,7 +38,9 @@ export class TinybenchEngine extends ModestBenchEngine {
|
|
|
33
38
|
): Promise<TaskResult> {
|
|
34
39
|
try {
|
|
35
40
|
if (!taskData.fn || typeof taskData.fn !== 'function') {
|
|
36
|
-
throw new
|
|
41
|
+
throw new StructureValidationError(
|
|
42
|
+
'Benchmark task must have a "fn" function property',
|
|
43
|
+
);
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
// Determine effective time and iterations based on limitBy mode
|
|
@@ -137,13 +144,13 @@ export class TinybenchEngine extends ModestBenchEngine {
|
|
|
137
144
|
await minimalBench.run();
|
|
138
145
|
} catch {
|
|
139
146
|
// If still failing, the operation is too fast even for tinybench
|
|
140
|
-
throw new
|
|
147
|
+
throw new OperationTooFastError(
|
|
141
148
|
`Benchmark operation is too fast to measure reliably (execution time < 1ns)`,
|
|
142
149
|
);
|
|
143
150
|
}
|
|
144
151
|
const minimalResults = minimalBench.results[0];
|
|
145
152
|
if (!minimalResults || minimalResults.error) {
|
|
146
|
-
throw new
|
|
153
|
+
throw new OperationTooFastError(
|
|
147
154
|
`Benchmark too fast to measure reliably: ${minimalResults?.error?.message || 'unknown error'}`,
|
|
148
155
|
);
|
|
149
156
|
}
|
|
@@ -180,7 +187,7 @@ export class TinybenchEngine extends ModestBenchEngine {
|
|
|
180
187
|
// Get results
|
|
181
188
|
const results = bench.results[0];
|
|
182
189
|
if (!results) {
|
|
183
|
-
throw new
|
|
190
|
+
throw new BenchmarkExecutionError('No benchmark results returned');
|
|
184
191
|
}
|
|
185
192
|
|
|
186
193
|
// Check if the task was aborted
|
|
@@ -251,7 +258,7 @@ export class TinybenchEngine extends ModestBenchEngine {
|
|
|
251
258
|
|
|
252
259
|
if (!minimalResults || minimalResults.error) {
|
|
253
260
|
// If retry also fails, just accept it failed
|
|
254
|
-
throw new
|
|
261
|
+
throw new OperationTooFastError(
|
|
255
262
|
`Benchmark operation is too fast to measure reliably`,
|
|
256
263
|
);
|
|
257
264
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the final output path for a reporter
|
|
5
|
+
*
|
|
6
|
+
* @param outputDir - Optional output directory from --output flag
|
|
7
|
+
* @param outputFile - Optional output filename from --output-file flag
|
|
8
|
+
* @param defaultFilename - Default filename to use if none specified
|
|
9
|
+
* @returns Resolved output path, or undefined if no output to file requested
|
|
10
|
+
*/
|
|
11
|
+
export const resolveOutputPath = (
|
|
12
|
+
outputDir?: string,
|
|
13
|
+
outputFile?: string,
|
|
14
|
+
defaultFilename?: string,
|
|
15
|
+
): string | undefined => {
|
|
16
|
+
// If outputFile is provided
|
|
17
|
+
if (outputFile) {
|
|
18
|
+
// If outputFile is absolute, use as-is
|
|
19
|
+
if (isAbsolute(outputFile)) {
|
|
20
|
+
return outputFile;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// If outputDir specified, join them
|
|
24
|
+
if (outputDir) {
|
|
25
|
+
return join(outputDir, outputFile);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Otherwise, resolve relative to cwd
|
|
29
|
+
return resolve(process.cwd(), outputFile);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Fall back to default behavior
|
|
33
|
+
if (outputDir && defaultFilename) {
|
|
34
|
+
return join(outputDir, defaultFilename);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return undefined;
|
|
38
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModestBench Custom Error System
|
|
3
|
+
*
|
|
4
|
+
* Base error classes providing structured error handling with error codes,
|
|
5
|
+
* documentation URLs, and consistent error display.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Base URL for error documentation
|
|
10
|
+
*/
|
|
11
|
+
const ERROR_DOC_BASE_URL =
|
|
12
|
+
'https://boneskull.github.io/modestbench/reference/errors';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Abstract base class for ModestBench aggregate errors
|
|
16
|
+
*
|
|
17
|
+
* Extends AggregateError to support multiple errors with ModestBench error
|
|
18
|
+
* system features.
|
|
19
|
+
*/
|
|
20
|
+
export abstract class ModestBenchAggregateError extends AggregateError {
|
|
21
|
+
/**
|
|
22
|
+
* Unique error code for this error type Must be in format:
|
|
23
|
+
* ERR_MB_CATEGORY_DESCRIPTION
|
|
24
|
+
*/
|
|
25
|
+
abstract readonly code: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Error name (matches class name)
|
|
29
|
+
*/
|
|
30
|
+
public override readonly name: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Create a new ModestBench aggregate error
|
|
34
|
+
*
|
|
35
|
+
* @param errors - Array of errors that occurred
|
|
36
|
+
* @param message - Human-readable error message
|
|
37
|
+
* @param options - Optional Error options (e.g., cause)
|
|
38
|
+
*/
|
|
39
|
+
constructor(errors: unknown[], message: string, options?: ErrorOptions) {
|
|
40
|
+
super(errors, message, options);
|
|
41
|
+
this.name = this.constructor.name;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get the documentation URL for this error
|
|
46
|
+
*
|
|
47
|
+
* Returns a URL to the error reference page with an anchor to the specific
|
|
48
|
+
* error.
|
|
49
|
+
*
|
|
50
|
+
* @returns Documentation URL
|
|
51
|
+
*/
|
|
52
|
+
getDocUrl(): string {
|
|
53
|
+
// Use the error class name as the anchor (e.g., ConfigValidationError -> #configvalidationerror)
|
|
54
|
+
const anchor = this.name.toLowerCase();
|
|
55
|
+
return `${ERROR_DOC_BASE_URL}#${anchor}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Convert error to string with code, documentation URL, and nested errors
|
|
60
|
+
*
|
|
61
|
+
* @returns Formatted error string
|
|
62
|
+
*/
|
|
63
|
+
override toString(): string {
|
|
64
|
+
let result = `${this.name} [${this.code}]: ${this.message}\n`;
|
|
65
|
+
result += `See: ${this.getDocUrl()}\n`;
|
|
66
|
+
|
|
67
|
+
if (this.errors.length > 0) {
|
|
68
|
+
result += `\nContains ${this.errors.length} error(s):\n`;
|
|
69
|
+
this.errors.forEach((err, index) => {
|
|
70
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
71
|
+
result += ` ${index + 1}. ${errMsg}\n`;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Abstract base class for all ModestBench errors
|
|
81
|
+
*
|
|
82
|
+
* Provides:
|
|
83
|
+
*
|
|
84
|
+
* - Unique error codes with ERR_MB_ prefix
|
|
85
|
+
* - Documentation URL generation
|
|
86
|
+
* - Consistent error display format
|
|
87
|
+
* - TypeScript type safety
|
|
88
|
+
*/
|
|
89
|
+
export abstract class ModestBenchError extends Error {
|
|
90
|
+
/**
|
|
91
|
+
* Unique error code for this error type Must be in format:
|
|
92
|
+
* ERR_MB_CATEGORY_DESCRIPTION
|
|
93
|
+
*/
|
|
94
|
+
abstract readonly code: string;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Error name (matches class name)
|
|
98
|
+
*/
|
|
99
|
+
public override readonly name: string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Create a new ModestBench error
|
|
103
|
+
*
|
|
104
|
+
* @param message - Human-readable error message
|
|
105
|
+
* @param options - Optional Error options (e.g., cause)
|
|
106
|
+
*/
|
|
107
|
+
constructor(message: string, options?: ErrorOptions) {
|
|
108
|
+
super(message, options);
|
|
109
|
+
this.name = this.constructor.name;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Get the documentation URL for this error
|
|
114
|
+
*
|
|
115
|
+
* Returns a URL to the error reference page with an anchor to the specific
|
|
116
|
+
* error.
|
|
117
|
+
*
|
|
118
|
+
* @returns Documentation URL
|
|
119
|
+
*/
|
|
120
|
+
getDocUrl(): string {
|
|
121
|
+
// Use the error class name as the anchor (e.g., ConfigValidationError -> #configvalidationerror)
|
|
122
|
+
const anchor = this.name.toLowerCase();
|
|
123
|
+
return `${ERROR_DOC_BASE_URL}#${anchor}`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Convert error to string with code and documentation URL
|
|
128
|
+
*
|
|
129
|
+
* @returns Formatted error string
|
|
130
|
+
*/
|
|
131
|
+
override toString(): string {
|
|
132
|
+
return `${this.name} [${this.code}]: ${this.message}\nSee: ${this.getDocUrl()}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Type guard to check if an error is a ModestBench error
|
|
138
|
+
*
|
|
139
|
+
* @param error - The error to check
|
|
140
|
+
* @returns True if the error is a ModestBench error
|
|
141
|
+
*/
|
|
142
|
+
export const isModestBenchError = (
|
|
143
|
+
error: unknown,
|
|
144
|
+
): error is ModestBenchError => {
|
|
145
|
+
return (
|
|
146
|
+
typeof error === 'object' &&
|
|
147
|
+
error !== null &&
|
|
148
|
+
'code' in error &&
|
|
149
|
+
typeof (error as { code: unknown }).code === 'string' &&
|
|
150
|
+
(error as { code: string }).code.startsWith('ERR_MB_')
|
|
151
|
+
);
|
|
152
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI-related errors
|
|
3
|
+
*
|
|
4
|
+
* Errors that occur during command-line interface operations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModestBenchError } from './base.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Invalid CLI argument
|
|
11
|
+
*
|
|
12
|
+
* Thrown when a CLI argument is invalid or cannot be parsed.
|
|
13
|
+
*/
|
|
14
|
+
export class InvalidArgumentError extends ModestBenchError {
|
|
15
|
+
readonly code = 'ERR_MB_CLI_INVALID_ARGUMENT';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Invalid date format
|
|
20
|
+
*
|
|
21
|
+
* Thrown when a date string cannot be parsed into a valid date.
|
|
22
|
+
*/
|
|
23
|
+
export class InvalidDateFormatError extends ModestBenchError {
|
|
24
|
+
readonly code = 'ERR_MB_CLI_INVALID_DATE_FORMAT';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Unknown error
|
|
29
|
+
*
|
|
30
|
+
* Thrown at the CLI boundary to wrap unexpected errors that are not ModestBench
|
|
31
|
+
* errors. This ensures all errors have proper structure and documentation
|
|
32
|
+
* links.
|
|
33
|
+
*/
|
|
34
|
+
export class UnknownError extends ModestBenchError {
|
|
35
|
+
readonly code = 'ERR_MB_UNKNOWN';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new UnknownError wrapping an unexpected error
|
|
39
|
+
*
|
|
40
|
+
* @param message - The error message (typically from the original error)
|
|
41
|
+
* @param options - Error options with the original error as the cause
|
|
42
|
+
*/
|
|
43
|
+
constructor(message: string, options: ErrorOptions) {
|
|
44
|
+
super(message, options);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Override toString to show full details of the wrapped error
|
|
49
|
+
*/
|
|
50
|
+
override toString(): string {
|
|
51
|
+
let result = super.toString();
|
|
52
|
+
|
|
53
|
+
if (this.cause instanceof Error && this.cause.stack) {
|
|
54
|
+
result += '\n\nOriginal error:\n' + this.cause.stack;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration-related errors
|
|
3
|
+
*
|
|
4
|
+
* Errors that occur during configuration file loading, parsing, and validation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModestBenchError } from './base.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Failed to load configuration
|
|
11
|
+
*
|
|
12
|
+
* Thrown when configuration loading fails for reasons other than file not found
|
|
13
|
+
* (e.g., parse errors, module loading errors).
|
|
14
|
+
*/
|
|
15
|
+
export class ConfigLoadError extends ModestBenchError {
|
|
16
|
+
readonly code = 'ERR_MB_CONFIG_LOAD_FAILED';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Configuration file not found
|
|
21
|
+
*
|
|
22
|
+
* Thrown when a specified configuration file cannot be found.
|
|
23
|
+
*/
|
|
24
|
+
export class ConfigNotFoundError extends ModestBenchError {
|
|
25
|
+
readonly code = 'ERR_MB_CONFIG_NOT_FOUND';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Configuration validation failed
|
|
30
|
+
*
|
|
31
|
+
* Thrown when a configuration file or configuration options fail schema
|
|
32
|
+
* validation.
|
|
33
|
+
*/
|
|
34
|
+
export class ConfigValidationError extends ModestBenchError {
|
|
35
|
+
readonly code = 'ERR_MB_CONFIG_VALIDATION_FAILED';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Unsupported configuration format
|
|
40
|
+
*
|
|
41
|
+
* Thrown when attempting to use an unsupported configuration file format.
|
|
42
|
+
*/
|
|
43
|
+
export class UnsupportedConfigFormatError extends ModestBenchError {
|
|
44
|
+
readonly code = 'ERR_MB_CONFIG_UNSUPPORTED_FORMAT';
|
|
45
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution-related errors
|
|
3
|
+
*
|
|
4
|
+
* Errors that occur during benchmark execution, setup, and teardown.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModestBenchError } from './base.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Benchmark execution failed
|
|
11
|
+
*
|
|
12
|
+
* Thrown when overall benchmark execution fails.
|
|
13
|
+
*/
|
|
14
|
+
export class BenchmarkExecutionError extends ModestBenchError {
|
|
15
|
+
readonly code = 'ERR_MB_EXECUTION_BENCHMARK_FAILED';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Operation too fast to measure
|
|
20
|
+
*
|
|
21
|
+
* Thrown when a benchmark operation executes so quickly that it cannot be
|
|
22
|
+
* reliably measured (typically < 1ns per operation).
|
|
23
|
+
*/
|
|
24
|
+
export class OperationTooFastError extends ModestBenchError {
|
|
25
|
+
readonly code = 'ERR_MB_EXECUTION_TOO_FAST';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Setup function failed
|
|
30
|
+
*
|
|
31
|
+
* Thrown when a benchmark setup function fails.
|
|
32
|
+
*/
|
|
33
|
+
export class SetupError extends ModestBenchError {
|
|
34
|
+
readonly code = 'ERR_MB_EXECUTION_SETUP_FAILED';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Task execution failed
|
|
39
|
+
*
|
|
40
|
+
* Thrown when a specific benchmark task fails during execution.
|
|
41
|
+
*/
|
|
42
|
+
export class TaskExecutionError extends ModestBenchError {
|
|
43
|
+
readonly code = 'ERR_MB_EXECUTION_TASK_FAILED';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Teardown function failed
|
|
48
|
+
*
|
|
49
|
+
* Thrown when a benchmark teardown function fails.
|
|
50
|
+
*/
|
|
51
|
+
export class TeardownError extends ModestBenchError {
|
|
52
|
+
readonly code = 'ERR_MB_EXECUTION_TEARDOWN_FAILED';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Execution timeout exceeded
|
|
57
|
+
*
|
|
58
|
+
* Thrown when a benchmark operation exceeds the configured timeout.
|
|
59
|
+
*/
|
|
60
|
+
export class TimeoutError extends ModestBenchError {
|
|
61
|
+
readonly code = 'ERR_MB_EXECUTION_TIMEOUT';
|
|
62
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-related errors
|
|
3
|
+
*
|
|
4
|
+
* Errors that occur during file discovery, loading, and access.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModestBenchError } from './base.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* File discovery failed
|
|
11
|
+
*
|
|
12
|
+
* Thrown when file discovery/glob pattern matching fails.
|
|
13
|
+
*/
|
|
14
|
+
export class FileDiscoveryError extends ModestBenchError {
|
|
15
|
+
readonly code = 'ERR_MB_FILE_DISCOVERY_FAILED';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Failed to load benchmark file
|
|
20
|
+
*
|
|
21
|
+
* Thrown when loading a benchmark file fails (e.g., import errors, syntax
|
|
22
|
+
* errors).
|
|
23
|
+
*/
|
|
24
|
+
export class FileLoadError extends ModestBenchError {
|
|
25
|
+
readonly code = 'ERR_MB_FILE_LOAD_FAILED';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Benchmark file not found
|
|
30
|
+
*
|
|
31
|
+
* Thrown when a benchmark file cannot be found or does not exist.
|
|
32
|
+
*/
|
|
33
|
+
export class FileNotFoundError extends ModestBenchError {
|
|
34
|
+
readonly code = 'ERR_MB_FILE_NOT_FOUND';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* File permission denied
|
|
39
|
+
*
|
|
40
|
+
* Thrown when file access is denied due to insufficient permissions.
|
|
41
|
+
*/
|
|
42
|
+
export class FilePermissionError extends ModestBenchError {
|
|
43
|
+
readonly code = 'ERR_MB_FILE_PERMISSION_DENIED';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Unsupported file extension
|
|
48
|
+
*
|
|
49
|
+
* Thrown when attempting to load a file with an unsupported extension.
|
|
50
|
+
*/
|
|
51
|
+
export class UnsupportedFileExtensionError extends ModestBenchError {
|
|
52
|
+
readonly code = 'ERR_MB_FILE_UNSUPPORTED_EXTENSION';
|
|
53
|
+
}
|