flexi-bench 0.0.0-alpha.1 → 0.0.0-alpha.3
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 +18 -0
- package/dist/api-types.d.ts +4 -1
- package/dist/benchmark-console-reporter.d.ts +8 -0
- package/dist/benchmark-console-reporter.js +31 -0
- package/dist/benchmark.d.ts +4 -4
- package/dist/benchmark.js +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/suite-console-reporter.d.ts +4 -0
- package/dist/suite-console-reporter.js +15 -0
- package/dist/suite.d.ts +17 -0
- package/dist/suite.js +46 -0
- package/package.json +2 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
## 0.0.0-alpha.3 (2024-07-11)
|
|
2
|
+
|
|
3
|
+
This was a version bump only, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 0.0.0-alpha.2 (2024-07-11)
|
|
6
|
+
|
|
7
|
+
This was a version bump only, there were no code changes.
|
|
8
|
+
|
|
9
|
+
## 0.0.0-alpha.1 (2024-07-11)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### 🚀 Features
|
|
13
|
+
|
|
14
|
+
- initial draft ([d999262](https://github.com/AgentEnder/easybench/commit/d999262))
|
|
15
|
+
|
|
16
|
+
### ❤️ Thank You
|
|
17
|
+
|
|
18
|
+
- Craigory Coppola @AgentEnder
|
package/dist/api-types.d.ts
CHANGED
|
@@ -18,7 +18,10 @@ export interface ProgressContext {
|
|
|
18
18
|
timeout?: number;
|
|
19
19
|
timeElapsed: number;
|
|
20
20
|
}
|
|
21
|
-
export interface
|
|
21
|
+
export interface BenchmarkReporter {
|
|
22
22
|
progress?: (name: string, progress: number, context: ProgressContext) => void;
|
|
23
23
|
report: (benchmark: Benchmark, results: Result[]) => void;
|
|
24
24
|
}
|
|
25
|
+
export interface SuiteReporter {
|
|
26
|
+
report: (results: Record<string, Result[]>) => void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Result, BenchmarkReporter, ProgressContext } from './api-types';
|
|
2
|
+
import { Benchmark } from './benchmark';
|
|
3
|
+
export declare class BenchmarkConsoleReporter implements BenchmarkReporter {
|
|
4
|
+
private bar;
|
|
5
|
+
constructor();
|
|
6
|
+
progress(name: string, percent: number, context: ProgressContext): void;
|
|
7
|
+
report(benchmark: Benchmark, results: Result[]): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BenchmarkConsoleReporter = void 0;
|
|
4
|
+
const cli_progress_1 = require("cli-progress");
|
|
5
|
+
class BenchmarkConsoleReporter {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.bar = new cli_progress_1.SingleBar({
|
|
8
|
+
format: 'Running: {label}\n{bar} {percentage}% | {value}/{total} - ETA: {eta}s',
|
|
9
|
+
barCompleteChar: '\u2588',
|
|
10
|
+
barIncompleteChar: '\u2591',
|
|
11
|
+
hideCursor: true,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
progress(name, percent, context) {
|
|
15
|
+
var _a;
|
|
16
|
+
if (!this.bar.isActive) {
|
|
17
|
+
this.bar.start((_a = context.totalIterations) !== null && _a !== void 0 ? _a : 100, 0);
|
|
18
|
+
}
|
|
19
|
+
this.bar.update(context.completedIterations, { label: name });
|
|
20
|
+
process.stdout.moveCursor(0, -1);
|
|
21
|
+
// console.log(`Progress: ${name} ${Math.round(percent * 10000) / 100}%`);
|
|
22
|
+
}
|
|
23
|
+
report(benchmark, results) {
|
|
24
|
+
this.bar.stop();
|
|
25
|
+
process.stdout.moveCursor(0, -1);
|
|
26
|
+
process.stdout.clearScreenDown();
|
|
27
|
+
console.log(`Benchmark: ${benchmark.name}`);
|
|
28
|
+
console.table(results);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.BenchmarkConsoleReporter = BenchmarkConsoleReporter;
|
package/dist/benchmark.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Variation } from './variation';
|
|
2
|
-
import {
|
|
2
|
+
import { BenchmarkReporter, Result } from './api-types';
|
|
3
3
|
import { ActionMethod } from './api-types';
|
|
4
4
|
import { TeardownMethod } from './api-types';
|
|
5
5
|
import { SetupMethod } from './api-types';
|
|
@@ -18,7 +18,7 @@ export declare class Benchmark {
|
|
|
18
18
|
action?: ActionMethod;
|
|
19
19
|
iterations?: number;
|
|
20
20
|
timeout?: number;
|
|
21
|
-
reporter?:
|
|
21
|
+
reporter?: BenchmarkReporter;
|
|
22
22
|
});
|
|
23
23
|
withVariation(name: string, builder: (variation: Variation) => Variation): this;
|
|
24
24
|
withVariations(variations: Variation[]): this;
|
|
@@ -27,7 +27,7 @@ export declare class Benchmark {
|
|
|
27
27
|
withAction(action: () => void): this;
|
|
28
28
|
withIterations(iterations: number): this;
|
|
29
29
|
withTimeout(timeout: number): this;
|
|
30
|
-
withReporter(reporter:
|
|
31
|
-
run(): Promise<
|
|
30
|
+
withReporter(reporter: BenchmarkReporter): this;
|
|
31
|
+
run(): Promise<Result[]>;
|
|
32
32
|
private validate;
|
|
33
33
|
}
|
package/dist/benchmark.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Benchmark = void 0;
|
|
13
|
-
const
|
|
13
|
+
const benchmark_console_reporter_1 = require("./benchmark-console-reporter");
|
|
14
14
|
const variation_1 = require("./variation");
|
|
15
15
|
class Benchmark {
|
|
16
16
|
constructor(name, options) {
|
|
@@ -33,7 +33,7 @@ class Benchmark {
|
|
|
33
33
|
if (options === null || options === void 0 ? void 0 : options.timeout) {
|
|
34
34
|
this.timeout = options.timeout;
|
|
35
35
|
}
|
|
36
|
-
this.reporter = (options === null || options === void 0 ? void 0 : options.reporter) || new
|
|
36
|
+
this.reporter = (options === null || options === void 0 ? void 0 : options.reporter) || new benchmark_console_reporter_1.BenchmarkConsoleReporter();
|
|
37
37
|
}
|
|
38
38
|
withVariation(name, builder) {
|
|
39
39
|
this.variations.push(builder(new variation_1.Variation(name)));
|
|
@@ -170,6 +170,7 @@ class Benchmark {
|
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
this.reporter.report(this, results);
|
|
173
|
+
return results;
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
176
|
validate() {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./api-types"), exports);
|
|
18
18
|
__exportStar(require("./benchmark"), exports);
|
|
19
19
|
__exportStar(require("./variation"), exports);
|
|
20
|
-
__exportStar(require("./console-reporter"), exports);
|
|
20
|
+
__exportStar(require("./benchmark-console-reporter"), exports);
|
|
21
|
+
__exportStar(require("./suite"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SuiteConsoleReporter = void 0;
|
|
4
|
+
class SuiteConsoleReporter {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.report = (results) => {
|
|
7
|
+
console.log('Suite Results:');
|
|
8
|
+
for (const [name, result] of Object.entries(results)) {
|
|
9
|
+
console.log(`Benchmark: ${name}`);
|
|
10
|
+
console.table(result);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.SuiteConsoleReporter = SuiteConsoleReporter;
|
package/dist/suite.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SuiteReporter } from './api-types';
|
|
2
|
+
import { Benchmark } from './benchmark';
|
|
3
|
+
import { Variation } from './variation';
|
|
4
|
+
export interface SuiteOptions {
|
|
5
|
+
reporter?: SuiteReporter;
|
|
6
|
+
}
|
|
7
|
+
export declare class Suite {
|
|
8
|
+
private name;
|
|
9
|
+
private benchmarks;
|
|
10
|
+
private variations;
|
|
11
|
+
private reporter;
|
|
12
|
+
constructor(name: string, options?: SuiteOptions);
|
|
13
|
+
addBenchmark(benchmark: Benchmark): this;
|
|
14
|
+
addVariation(variation: Variation): this;
|
|
15
|
+
addVariations(variations: Variation[]): this;
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
package/dist/suite.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Suite = void 0;
|
|
13
|
+
const suite_console_reporter_1 = require("./suite-console-reporter");
|
|
14
|
+
class Suite {
|
|
15
|
+
constructor(name, options) {
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.benchmarks = [];
|
|
18
|
+
this.variations = [];
|
|
19
|
+
this.name = name;
|
|
20
|
+
this.benchmarks = [];
|
|
21
|
+
this.reporter = (options === null || options === void 0 ? void 0 : options.reporter) || new suite_console_reporter_1.SuiteConsoleReporter();
|
|
22
|
+
}
|
|
23
|
+
addBenchmark(benchmark) {
|
|
24
|
+
this.benchmarks.push(benchmark);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
addVariation(variation) {
|
|
28
|
+
this.variations.push(variation);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
addVariations(variations) {
|
|
32
|
+
this.variations.push(...variations);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
run() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const results = {};
|
|
38
|
+
for (const benchmark of this.benchmarks) {
|
|
39
|
+
benchmark.withVariations(this.variations);
|
|
40
|
+
results[benchmark.name] = yield benchmark.run();
|
|
41
|
+
}
|
|
42
|
+
this.reporter.report(results);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.Suite = Suite;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flexi-bench",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"dist",
|
|
30
30
|
"README.md",
|
|
31
31
|
"LICENSE",
|
|
32
|
+
"CHANGELOG.md",
|
|
32
33
|
"package.json"
|
|
33
34
|
]
|
|
34
35
|
}
|