flexi-bench 0.0.0-alpha.2 → 0.0.0-alpha.4
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 +19 -0
- package/README.md +373 -0
- package/dist/api-types.d.ts +7 -8
- package/dist/benchmark-runner.d.ts +79 -0
- package/dist/benchmark-runner.js +172 -0
- package/dist/benchmark.d.ts +15 -15
- package/dist/benchmark.js +82 -22
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/performance-observer.d.ts +12 -0
- package/dist/performance-observer.js +60 -0
- package/dist/reporters/benchmark-console-reporter.d.ts +10 -0
- package/dist/{console-reporter.js → reporters/benchmark-console-reporter.js} +6 -9
- package/dist/reporters/markdown-benchmark-reporter.d.ts +12 -0
- package/dist/reporters/markdown-benchmark-reporter.js +29 -0
- package/dist/reporters/noop-reporter.d.ts +4 -0
- package/dist/reporters/noop-reporter.js +9 -0
- package/dist/reporters/suite-console-reporter.d.ts +5 -0
- package/dist/reporters/suite-console-reporter.js +15 -0
- package/dist/results.d.ts +34 -0
- package/dist/results.js +14 -0
- package/dist/shared-api.d.ts +13 -0
- package/dist/shared-api.js +32 -0
- package/dist/suite.d.ts +21 -0
- package/dist/suite.js +58 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +14 -0
- package/dist/variation.d.ts +22 -8
- package/dist/variation.js +33 -13
- package/package.json +23 -9
- package/dist/console-reporter.d.ts +0 -8
package/dist/variation.d.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { EnvironmentVariableOptions } from './api-types';
|
|
2
|
+
import { BenchmarkBase } from './shared-api';
|
|
3
|
+
export declare class Variation extends BenchmarkBase {
|
|
3
4
|
name: string;
|
|
4
|
-
setupMethods: SetupMethod[];
|
|
5
|
-
teardownMethods: TeardownMethod[];
|
|
6
5
|
environment: Partial<NodeJS.ProcessEnv>;
|
|
7
|
-
|
|
6
|
+
cliArgs: string[];
|
|
8
7
|
constructor(name: string);
|
|
9
8
|
static FromEnvironmentVariables(variables: EnvironmentVariableOptions): Variation[];
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param args An array of options to pass to the CLI. If an element is an array, they will be treated as alternatives.
|
|
12
|
+
* @returns An array of variations. Can be applied with `withVariations`.
|
|
13
|
+
* @example
|
|
14
|
+
* // Creates 2 variations, both with --flag, but one with --no-daemon and the other with --daemon.
|
|
15
|
+
* const variations = Variation.FromCliArgs([
|
|
16
|
+
* '--flag',
|
|
17
|
+
* ['--no-daemon', '--daemon'],
|
|
18
|
+
* ]);
|
|
19
|
+
*
|
|
20
|
+
* // Creates 4 variations, with combinations of --a and --b.
|
|
21
|
+
* const variations = Variation.FromCliArgs([
|
|
22
|
+
* ['--a', '--b'],
|
|
23
|
+
* ]);
|
|
24
|
+
*/
|
|
25
|
+
static FromCliArgs(args: Array<string | string[]>): Variation[];
|
|
12
26
|
withEnvironmentVariables(env: Partial<NodeJS.ProcessEnv>): this;
|
|
13
27
|
withEnvironmentVariable(name: string, value: string): this;
|
|
14
|
-
|
|
28
|
+
withCliArgs(...args: string[]): this;
|
|
15
29
|
}
|
package/dist/variation.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Variation = void 0;
|
|
4
|
-
|
|
4
|
+
const shared_api_1 = require("./shared-api");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
class Variation extends shared_api_1.BenchmarkBase {
|
|
5
7
|
constructor(name) {
|
|
8
|
+
super();
|
|
6
9
|
this.name = name;
|
|
7
|
-
this.setupMethods = [];
|
|
8
|
-
this.teardownMethods = [];
|
|
9
10
|
this.environment = {};
|
|
11
|
+
this.cliArgs = [];
|
|
10
12
|
}
|
|
11
13
|
static FromEnvironmentVariables(variables) {
|
|
12
|
-
const combinations = variables.
|
|
14
|
+
const combinations = (0, utils_1.findCombinations)(variables.map(([name, values]) => values.map((value) => [name, value])));
|
|
15
|
+
variables.reduce((acc, [name, values]) => {
|
|
13
16
|
return acc.flatMap((accItem) => {
|
|
14
17
|
return values.map((value) => {
|
|
15
18
|
return [...accItem, [name, value]];
|
|
@@ -21,13 +24,30 @@ class Variation {
|
|
|
21
24
|
return new Variation(label).withEnvironmentVariables(Object.fromEntries(combination));
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param args An array of options to pass to the CLI. If an element is an array, they will be treated as alternatives.
|
|
30
|
+
* @returns An array of variations. Can be applied with `withVariations`.
|
|
31
|
+
* @example
|
|
32
|
+
* // Creates 2 variations, both with --flag, but one with --no-daemon and the other with --daemon.
|
|
33
|
+
* const variations = Variation.FromCliArgs([
|
|
34
|
+
* '--flag',
|
|
35
|
+
* ['--no-daemon', '--daemon'],
|
|
36
|
+
* ]);
|
|
37
|
+
*
|
|
38
|
+
* // Creates 4 variations, with combinations of --a and --b.
|
|
39
|
+
* const variations = Variation.FromCliArgs([
|
|
40
|
+
* ['--a', '--b'],
|
|
41
|
+
* ]);
|
|
42
|
+
*/
|
|
43
|
+
static FromCliArgs(args) {
|
|
44
|
+
const alternatives = args.filter(Array.isArray);
|
|
45
|
+
const values = (0, utils_1.findCombinations)(alternatives);
|
|
46
|
+
return values.flatMap((alts) => {
|
|
47
|
+
const cliArgs = args.map((arg) => Array.isArray(arg) ? alts.shift() : arg);
|
|
48
|
+
const label = cliArgs.join(' ');
|
|
49
|
+
return new Variation(label).withCliArgs(...cliArgs);
|
|
50
|
+
});
|
|
31
51
|
}
|
|
32
52
|
withEnvironmentVariables(env) {
|
|
33
53
|
this.environment = Object.assign(Object.assign({}, this.environment), env);
|
|
@@ -37,8 +57,8 @@ class Variation {
|
|
|
37
57
|
this.environment[name] = value;
|
|
38
58
|
return this;
|
|
39
59
|
}
|
|
40
|
-
|
|
41
|
-
this.
|
|
60
|
+
withCliArgs(...args) {
|
|
61
|
+
this.cliArgs = this.cliArgs.concat(args);
|
|
42
62
|
return this;
|
|
43
63
|
}
|
|
44
64
|
}
|
package/package.json
CHANGED
|
@@ -1,35 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flexi-bench",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/AgentEnder/flexi-bench"
|
|
9
|
+
},
|
|
6
10
|
"scripts": {
|
|
7
|
-
"test": "
|
|
11
|
+
"test": "node --import tsx --test './src/**/*.spec.ts'",
|
|
12
|
+
"test:watch": "node --import tsx --test --watch './src/**/*.spec.ts'",
|
|
8
13
|
"build": "tsc -p tsconfig.json",
|
|
9
14
|
"format": "prettier --write src"
|
|
10
15
|
},
|
|
11
16
|
"author": "",
|
|
12
|
-
"license": "
|
|
17
|
+
"license": "MIT",
|
|
13
18
|
"devDependencies": {
|
|
14
19
|
"@nx/js": "^19.4.2",
|
|
15
20
|
"@swc-node/register": "~1.9.1",
|
|
16
21
|
"@swc/core": "~1.5.7",
|
|
17
22
|
"@swc/helpers": "~0.5.11",
|
|
18
|
-
"nx": "19.4.2"
|
|
19
|
-
},
|
|
20
|
-
"nx": {},
|
|
21
|
-
"dependencies": {
|
|
22
23
|
"@types/cli-progress": "^3.11.6",
|
|
23
24
|
"@types/node": "^20.14.10",
|
|
24
|
-
"
|
|
25
|
+
"nx": "19.4.2",
|
|
25
26
|
"prettier": "^3.3.2",
|
|
26
|
-
"
|
|
27
|
+
"ts-node": "^10.9.2",
|
|
28
|
+
"tsx": "^4.16.2",
|
|
29
|
+
"typescript": "^5.5.3",
|
|
30
|
+
"yaml": "^2.4.5"
|
|
27
31
|
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"cli-progress": "^3.12.0",
|
|
34
|
+
"markdown-factory": "^0.0.6"
|
|
35
|
+
},
|
|
36
|
+
"nx": {},
|
|
28
37
|
"files": [
|
|
29
38
|
"dist",
|
|
30
39
|
"README.md",
|
|
31
40
|
"LICENSE",
|
|
32
41
|
"CHANGELOG.md",
|
|
33
42
|
"package.json"
|
|
43
|
+
],
|
|
44
|
+
"workspaces": [
|
|
45
|
+
".",
|
|
46
|
+
"docs-site",
|
|
47
|
+
"packages/*"
|
|
34
48
|
]
|
|
35
49
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Result, Reporter, ProgressContext } from './api-types';
|
|
2
|
-
import { Benchmark } from './benchmark';
|
|
3
|
-
export declare class ConsoleReporter implements Reporter {
|
|
4
|
-
private bar;
|
|
5
|
-
constructor();
|
|
6
|
-
progress(name: string, percent: number, context: ProgressContext): void;
|
|
7
|
-
report(benchmark: Benchmark, results: Result[]): void;
|
|
8
|
-
}
|