@autobe/benchmark 0.30.0-dev.20260315 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -661
- package/lib/example/AutoBeExampleLogger.js +16 -16
- package/lib/replay/AutoBeReplayDocumentation.js +39 -39
- package/package.json +4 -4
- package/src/example/AutoBeExampleArchiver.ts +381 -381
- package/src/example/AutoBeExampleBenchmark.ts +190 -190
- package/src/example/AutoBeExampleLogger.ts +85 -85
- package/src/example/AutoBeExampleStorage.ts +289 -289
- package/src/example/index.ts +4 -4
- package/src/index.ts +2 -2
- package/src/replay/AutoBeReplayComputer.ts +183 -183
- package/src/replay/AutoBeReplayDocumentation.ts +176 -176
- package/src/replay/AutoBeReplayStorage.ts +116 -116
- package/src/replay/index.ts +3 -3
- package/src/structures/IAutoBeExampleBenchmarkState.ts +30 -30
- package/src/structures/index.ts +1 -1
- package/README.md +0 -261
|
@@ -1,176 +1,176 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AutoBeExampleProject,
|
|
3
|
-
AutoBePhase,
|
|
4
|
-
IAutoBePlaygroundBenchmark,
|
|
5
|
-
IAutoBePlaygroundReplay,
|
|
6
|
-
} from "@autobe/interface";
|
|
7
|
-
import { StringUtil } from "@autobe/utils";
|
|
8
|
-
|
|
9
|
-
import { AutoBeExampleStorage } from "../example/AutoBeExampleStorage";
|
|
10
|
-
|
|
11
|
-
export namespace AutoBeReplayDocumentation {
|
|
12
|
-
export const readme = (experiments: IAutoBePlaygroundBenchmark[]): string => {
|
|
13
|
-
return StringUtil.trim`
|
|
14
|
-
# AutoBe Generated Examples
|
|
15
|
-
|
|
16
|
-
## Benchmark
|
|
17
|
-
|
|
18
|
-
AI Model | Success | Score | FCSR | Status
|
|
19
|
-
:--------|---------|------:|-----:|:------:
|
|
20
|
-
${experiments
|
|
21
|
-
.map((e) =>
|
|
22
|
-
[
|
|
23
|
-
`[\`${AutoBeExampleStorage.slugModel(
|
|
24
|
-
e.vendor,
|
|
25
|
-
false,
|
|
26
|
-
)}\`](#${AutoBeExampleStorage.slugModel(e.vendor, false)
|
|
27
|
-
.replaceAll("/", "")
|
|
28
|
-
.replaceAll(".", "")})`,
|
|
29
|
-
e.replays.filter((r) => r.realize?.success === true).length,
|
|
30
|
-
e.score.aggregate,
|
|
31
|
-
(() => {
|
|
32
|
-
const [x, y] = e.replays
|
|
33
|
-
.map((r) => r.aggregates.total.metric)
|
|
34
|
-
.map((m) => [m.success, m.attempt])
|
|
35
|
-
.reduce((a, b) => [a[0] + b[0], a[1] + b[1]], [0, 0]);
|
|
36
|
-
return y === 0 ? "0%" : Math.floor((x / y) * 100) + "%";
|
|
37
|
-
})(),
|
|
38
|
-
e.emoji,
|
|
39
|
-
].join(" | "),
|
|
40
|
-
)
|
|
41
|
-
.join("\n")}
|
|
42
|
-
|
|
43
|
-
- FCSR: Function Calling Success Rate
|
|
44
|
-
- Status:
|
|
45
|
-
- 🟢: All projects completed successfully
|
|
46
|
-
- 🟡: Some projects failed
|
|
47
|
-
- ❌: All projects failed or not executed
|
|
48
|
-
|
|
49
|
-
${experiments.map(vendor).join("\n\n\n")}
|
|
50
|
-
`;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const vendor = (exp: IAutoBePlaygroundBenchmark): string => {
|
|
54
|
-
const row = (project: AutoBeExampleProject): string => {
|
|
55
|
-
const found = exp.replays.find((r) => r.project === project);
|
|
56
|
-
if (found === undefined)
|
|
57
|
-
return `\`${project}\` | 0 | ❌ | ❌ | ❌ | ❌ | ❌`;
|
|
58
|
-
const phase = (
|
|
59
|
-
state: IAutoBePlaygroundReplay.IPhaseState | null,
|
|
60
|
-
): string => {
|
|
61
|
-
if (state === null) return "❌";
|
|
62
|
-
else if (state.success === false) return "🟡";
|
|
63
|
-
else return "🟢";
|
|
64
|
-
};
|
|
65
|
-
return [
|
|
66
|
-
`[\`${found.project}\`](./${exp.vendor}/${found.project}/)`,
|
|
67
|
-
// biome-ignore lint: intended
|
|
68
|
-
(exp.score as any)[project],
|
|
69
|
-
phase(found.analyze),
|
|
70
|
-
phase(found.database),
|
|
71
|
-
phase(found.interface),
|
|
72
|
-
phase(found.test),
|
|
73
|
-
phase(found.realize),
|
|
74
|
-
].join(" | ");
|
|
75
|
-
};
|
|
76
|
-
return StringUtil.trim`
|
|
77
|
-
## \`${exp.vendor}\`
|
|
78
|
-
|
|
79
|
-
Project | Score | Analyze | Prisma | Interface | Test | Realize
|
|
80
|
-
:-------|------:|:-------:|:------:|:----------|:----:|:-------:
|
|
81
|
-
${row("todo")}
|
|
82
|
-
${row("bbs")}
|
|
83
|
-
${row("reddit")}
|
|
84
|
-
${row("shopping")}
|
|
85
|
-
|
|
86
|
-
${exp.replays
|
|
87
|
-
.map((r) =>
|
|
88
|
-
project({
|
|
89
|
-
replay: r,
|
|
90
|
-
// biome-ignore lint: intended
|
|
91
|
-
score: (exp.score as any)[r.project],
|
|
92
|
-
}),
|
|
93
|
-
)
|
|
94
|
-
.join("\n\n\n")}
|
|
95
|
-
`;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const project = (props: {
|
|
99
|
-
replay: IAutoBePlaygroundReplay.ISummary;
|
|
100
|
-
score: number;
|
|
101
|
-
}): string => {
|
|
102
|
-
const phase = (key: AutoBePhase): string => {
|
|
103
|
-
const title: string = key.charAt(0).toUpperCase() + key.slice(1);
|
|
104
|
-
const state: IAutoBePlaygroundReplay.IPhaseState | null =
|
|
105
|
-
props.replay[key];
|
|
106
|
-
if (state === null) return [`⚪ ${title}`, "", "", "", ""].join(" | ");
|
|
107
|
-
return [
|
|
108
|
-
`${state.success === true ? "🟢" : Object.keys(state.commodity).length ? "🟡" : "🔴"} ${title}`,
|
|
109
|
-
Object.entries(state.commodity)
|
|
110
|
-
.map(([key, value]) => `\`${key}\`: ${value}`)
|
|
111
|
-
.join(", "),
|
|
112
|
-
formatTokens(state.aggregates.total.tokenUsage.total),
|
|
113
|
-
formatElapsedTime(state.elapsed),
|
|
114
|
-
Math.floor(
|
|
115
|
-
(state.aggregates.total.metric.success /
|
|
116
|
-
state.aggregates.total.metric.attempt) *
|
|
117
|
-
100,
|
|
118
|
-
) + "%",
|
|
119
|
-
].join(" | ");
|
|
120
|
-
};
|
|
121
|
-
return StringUtil.trim`
|
|
122
|
-
### \`${props.replay.vendor}\` - \`${props.replay.project}\`
|
|
123
|
-
|
|
124
|
-
- Source Code: ${`[\`${AutoBeExampleStorage.slugModel(
|
|
125
|
-
props.replay.vendor,
|
|
126
|
-
false,
|
|
127
|
-
)}/${props.replay.project}\`](./${AutoBeExampleStorage.slugModel(
|
|
128
|
-
props.replay.vendor,
|
|
129
|
-
false,
|
|
130
|
-
)}/${props.replay.project}/)`}
|
|
131
|
-
- Score: ${props.score}
|
|
132
|
-
- Elapsed Time: ${formatElapsedTime(props.replay.elapsed)}
|
|
133
|
-
- Token Usage: ${formatTokens(
|
|
134
|
-
props.replay.aggregates.total.tokenUsage.total,
|
|
135
|
-
)}
|
|
136
|
-
- Function Calling Success Rate: ${(
|
|
137
|
-
(props.replay.aggregates.total.metric.success /
|
|
138
|
-
props.replay.aggregates.total.metric.attempt) *
|
|
139
|
-
100
|
|
140
|
-
).toFixed(2)}%
|
|
141
|
-
|
|
142
|
-
Phase | Generated | Token Usage | Elapsed Time | FCSR
|
|
143
|
-
:-----|:----------|------------:|-------------:|------:
|
|
144
|
-
${(["analyze", "database", "interface", "test", "realize"] as const)
|
|
145
|
-
.map((key) => phase(key))
|
|
146
|
-
.join("\n")}
|
|
147
|
-
`;
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function formatElapsedTime(ms: number): string {
|
|
152
|
-
const seconds = Math.floor(ms / 1000);
|
|
153
|
-
const minutes = Math.floor(seconds / 60);
|
|
154
|
-
const hours = Math.floor(minutes / 60);
|
|
155
|
-
|
|
156
|
-
const s = seconds % 60;
|
|
157
|
-
const m = minutes % 60;
|
|
158
|
-
const h = hours;
|
|
159
|
-
|
|
160
|
-
if (h > 0) {
|
|
161
|
-
return `${h}h ${m}m ${s}s`;
|
|
162
|
-
} else if (m > 0) {
|
|
163
|
-
return `${m}m ${s}s`;
|
|
164
|
-
} else {
|
|
165
|
-
return `${s}s`;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function formatTokens(num: number): string {
|
|
170
|
-
if (num >= 1000000) {
|
|
171
|
-
return `${(num / 1000000).toFixed(2)}M`;
|
|
172
|
-
} else if (num >= 1000) {
|
|
173
|
-
return `${(num / 1000).toFixed(1)}K`;
|
|
174
|
-
}
|
|
175
|
-
return num.toString();
|
|
176
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
AutoBeExampleProject,
|
|
3
|
+
AutoBePhase,
|
|
4
|
+
IAutoBePlaygroundBenchmark,
|
|
5
|
+
IAutoBePlaygroundReplay,
|
|
6
|
+
} from "@autobe/interface";
|
|
7
|
+
import { StringUtil } from "@autobe/utils";
|
|
8
|
+
|
|
9
|
+
import { AutoBeExampleStorage } from "../example/AutoBeExampleStorage";
|
|
10
|
+
|
|
11
|
+
export namespace AutoBeReplayDocumentation {
|
|
12
|
+
export const readme = (experiments: IAutoBePlaygroundBenchmark[]): string => {
|
|
13
|
+
return StringUtil.trim`
|
|
14
|
+
# AutoBe Generated Examples
|
|
15
|
+
|
|
16
|
+
## Benchmark
|
|
17
|
+
|
|
18
|
+
AI Model | Success | Score | FCSR | Status
|
|
19
|
+
:--------|---------|------:|-----:|:------:
|
|
20
|
+
${experiments
|
|
21
|
+
.map((e) =>
|
|
22
|
+
[
|
|
23
|
+
`[\`${AutoBeExampleStorage.slugModel(
|
|
24
|
+
e.vendor,
|
|
25
|
+
false,
|
|
26
|
+
)}\`](#${AutoBeExampleStorage.slugModel(e.vendor, false)
|
|
27
|
+
.replaceAll("/", "")
|
|
28
|
+
.replaceAll(".", "")})`,
|
|
29
|
+
e.replays.filter((r) => r.realize?.success === true).length,
|
|
30
|
+
e.score.aggregate,
|
|
31
|
+
(() => {
|
|
32
|
+
const [x, y] = e.replays
|
|
33
|
+
.map((r) => r.aggregates.total.metric)
|
|
34
|
+
.map((m) => [m.success, m.attempt])
|
|
35
|
+
.reduce((a, b) => [a[0] + b[0], a[1] + b[1]], [0, 0]);
|
|
36
|
+
return y === 0 ? "0%" : Math.floor((x / y) * 100) + "%";
|
|
37
|
+
})(),
|
|
38
|
+
e.emoji,
|
|
39
|
+
].join(" | "),
|
|
40
|
+
)
|
|
41
|
+
.join("\n")}
|
|
42
|
+
|
|
43
|
+
- FCSR: Function Calling Success Rate
|
|
44
|
+
- Status:
|
|
45
|
+
- 🟢: All projects completed successfully
|
|
46
|
+
- 🟡: Some projects failed
|
|
47
|
+
- ❌: All projects failed or not executed
|
|
48
|
+
|
|
49
|
+
${experiments.map(vendor).join("\n\n\n")}
|
|
50
|
+
`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const vendor = (exp: IAutoBePlaygroundBenchmark): string => {
|
|
54
|
+
const row = (project: AutoBeExampleProject): string => {
|
|
55
|
+
const found = exp.replays.find((r) => r.project === project);
|
|
56
|
+
if (found === undefined)
|
|
57
|
+
return `\`${project}\` | 0 | ❌ | ❌ | ❌ | ❌ | ❌`;
|
|
58
|
+
const phase = (
|
|
59
|
+
state: IAutoBePlaygroundReplay.IPhaseState | null,
|
|
60
|
+
): string => {
|
|
61
|
+
if (state === null) return "❌";
|
|
62
|
+
else if (state.success === false) return "🟡";
|
|
63
|
+
else return "🟢";
|
|
64
|
+
};
|
|
65
|
+
return [
|
|
66
|
+
`[\`${found.project}\`](./${exp.vendor}/${found.project}/)`,
|
|
67
|
+
// biome-ignore lint: intended
|
|
68
|
+
(exp.score as any)[project],
|
|
69
|
+
phase(found.analyze),
|
|
70
|
+
phase(found.database),
|
|
71
|
+
phase(found.interface),
|
|
72
|
+
phase(found.test),
|
|
73
|
+
phase(found.realize),
|
|
74
|
+
].join(" | ");
|
|
75
|
+
};
|
|
76
|
+
return StringUtil.trim`
|
|
77
|
+
## \`${exp.vendor}\`
|
|
78
|
+
|
|
79
|
+
Project | Score | Analyze | Prisma | Interface | Test | Realize
|
|
80
|
+
:-------|------:|:-------:|:------:|:----------|:----:|:-------:
|
|
81
|
+
${row("todo")}
|
|
82
|
+
${row("bbs")}
|
|
83
|
+
${row("reddit")}
|
|
84
|
+
${row("shopping")}
|
|
85
|
+
|
|
86
|
+
${exp.replays
|
|
87
|
+
.map((r) =>
|
|
88
|
+
project({
|
|
89
|
+
replay: r,
|
|
90
|
+
// biome-ignore lint: intended
|
|
91
|
+
score: (exp.score as any)[r.project],
|
|
92
|
+
}),
|
|
93
|
+
)
|
|
94
|
+
.join("\n\n\n")}
|
|
95
|
+
`;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const project = (props: {
|
|
99
|
+
replay: IAutoBePlaygroundReplay.ISummary;
|
|
100
|
+
score: number;
|
|
101
|
+
}): string => {
|
|
102
|
+
const phase = (key: AutoBePhase): string => {
|
|
103
|
+
const title: string = key.charAt(0).toUpperCase() + key.slice(1);
|
|
104
|
+
const state: IAutoBePlaygroundReplay.IPhaseState | null =
|
|
105
|
+
props.replay[key];
|
|
106
|
+
if (state === null) return [`⚪ ${title}`, "", "", "", ""].join(" | ");
|
|
107
|
+
return [
|
|
108
|
+
`${state.success === true ? "🟢" : Object.keys(state.commodity).length ? "🟡" : "🔴"} ${title}`,
|
|
109
|
+
Object.entries(state.commodity)
|
|
110
|
+
.map(([key, value]) => `\`${key}\`: ${value}`)
|
|
111
|
+
.join(", "),
|
|
112
|
+
formatTokens(state.aggregates.total.tokenUsage.total),
|
|
113
|
+
formatElapsedTime(state.elapsed),
|
|
114
|
+
Math.floor(
|
|
115
|
+
(state.aggregates.total.metric.success /
|
|
116
|
+
state.aggregates.total.metric.attempt) *
|
|
117
|
+
100,
|
|
118
|
+
) + "%",
|
|
119
|
+
].join(" | ");
|
|
120
|
+
};
|
|
121
|
+
return StringUtil.trim`
|
|
122
|
+
### \`${props.replay.vendor}\` - \`${props.replay.project}\`
|
|
123
|
+
|
|
124
|
+
- Source Code: ${`[\`${AutoBeExampleStorage.slugModel(
|
|
125
|
+
props.replay.vendor,
|
|
126
|
+
false,
|
|
127
|
+
)}/${props.replay.project}\`](./${AutoBeExampleStorage.slugModel(
|
|
128
|
+
props.replay.vendor,
|
|
129
|
+
false,
|
|
130
|
+
)}/${props.replay.project}/)`}
|
|
131
|
+
- Score: ${props.score}
|
|
132
|
+
- Elapsed Time: ${formatElapsedTime(props.replay.elapsed)}
|
|
133
|
+
- Token Usage: ${formatTokens(
|
|
134
|
+
props.replay.aggregates.total.tokenUsage.total,
|
|
135
|
+
)}
|
|
136
|
+
- Function Calling Success Rate: ${(
|
|
137
|
+
(props.replay.aggregates.total.metric.success /
|
|
138
|
+
props.replay.aggregates.total.metric.attempt) *
|
|
139
|
+
100
|
|
140
|
+
).toFixed(2)}%
|
|
141
|
+
|
|
142
|
+
Phase | Generated | Token Usage | Elapsed Time | FCSR
|
|
143
|
+
:-----|:----------|------------:|-------------:|------:
|
|
144
|
+
${(["analyze", "database", "interface", "test", "realize"] as const)
|
|
145
|
+
.map((key) => phase(key))
|
|
146
|
+
.join("\n")}
|
|
147
|
+
`;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function formatElapsedTime(ms: number): string {
|
|
152
|
+
const seconds = Math.floor(ms / 1000);
|
|
153
|
+
const minutes = Math.floor(seconds / 60);
|
|
154
|
+
const hours = Math.floor(minutes / 60);
|
|
155
|
+
|
|
156
|
+
const s = seconds % 60;
|
|
157
|
+
const m = minutes % 60;
|
|
158
|
+
const h = hours;
|
|
159
|
+
|
|
160
|
+
if (h > 0) {
|
|
161
|
+
return `${h}h ${m}m ${s}s`;
|
|
162
|
+
} else if (m > 0) {
|
|
163
|
+
return `${m}m ${s}s`;
|
|
164
|
+
} else {
|
|
165
|
+
return `${s}s`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function formatTokens(num: number): string {
|
|
170
|
+
if (num >= 1000000) {
|
|
171
|
+
return `${(num / 1000000).toFixed(2)}M`;
|
|
172
|
+
} else if (num >= 1000) {
|
|
173
|
+
return `${(num / 1000).toFixed(1)}K`;
|
|
174
|
+
}
|
|
175
|
+
return num.toString();
|
|
176
|
+
}
|
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import { CompressUtil } from "@autobe/filesystem";
|
|
2
|
-
import {
|
|
3
|
-
AutoBeEventSnapshot,
|
|
4
|
-
AutoBeExampleProject,
|
|
5
|
-
AutoBeHistory,
|
|
6
|
-
AutoBePhase,
|
|
7
|
-
IAutoBePlaygroundReplay,
|
|
8
|
-
} from "@autobe/interface";
|
|
9
|
-
import fs from "fs";
|
|
10
|
-
import typia from "typia";
|
|
11
|
-
|
|
12
|
-
import { AutoBeExampleStorage } from "../example/AutoBeExampleStorage";
|
|
13
|
-
|
|
14
|
-
export namespace AutoBeReplayStorage {
|
|
15
|
-
export const getAll = async (
|
|
16
|
-
vendor: string,
|
|
17
|
-
projectFilter?: (project: AutoBeExampleProject) => boolean,
|
|
18
|
-
): Promise<IAutoBePlaygroundReplay[]> => {
|
|
19
|
-
const projects: AutoBeExampleProject[] = typia.misc
|
|
20
|
-
.literals<AutoBeExampleProject>()
|
|
21
|
-
.filter(projectFilter ?? (() => true));
|
|
22
|
-
const replays: Array<IAutoBePlaygroundReplay | null> = await Promise.all(
|
|
23
|
-
projects.map((p) =>
|
|
24
|
-
AutoBeReplayStorage.get({
|
|
25
|
-
vendor,
|
|
26
|
-
project: p,
|
|
27
|
-
}),
|
|
28
|
-
),
|
|
29
|
-
);
|
|
30
|
-
return replays.filter((r) => r !== null);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const getAllSummaries = async (
|
|
34
|
-
vendor: string,
|
|
35
|
-
projectFilter?: (project: AutoBeExampleProject) => boolean,
|
|
36
|
-
): Promise<IAutoBePlaygroundReplay.ISummary[]> => {
|
|
37
|
-
const projects: AutoBeExampleProject[] = typia.misc
|
|
38
|
-
.literals<AutoBeExampleProject>()
|
|
39
|
-
.filter(projectFilter ?? (() => true));
|
|
40
|
-
const summaries: Array<IAutoBePlaygroundReplay.ISummary | null> =
|
|
41
|
-
await Promise.all(
|
|
42
|
-
projects.map((project) =>
|
|
43
|
-
AutoBeReplayStorage.getSummary({ vendor, project }),
|
|
44
|
-
),
|
|
45
|
-
);
|
|
46
|
-
return summaries.filter((s) => s !== null);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const get = async (props: {
|
|
50
|
-
vendor: string;
|
|
51
|
-
project: AutoBeExampleProject;
|
|
52
|
-
}): Promise<IAutoBePlaygroundReplay | null> => {
|
|
53
|
-
const histories: AutoBeHistory[] | null = await getHistories(props);
|
|
54
|
-
if (histories === null) return null;
|
|
55
|
-
|
|
56
|
-
const snapshots = async (
|
|
57
|
-
phase: AutoBePhase,
|
|
58
|
-
): Promise<AutoBeEventSnapshot[] | null> => {
|
|
59
|
-
try {
|
|
60
|
-
return await AutoBeExampleStorage.getSnapshots({
|
|
61
|
-
vendor: props.vendor,
|
|
62
|
-
project: props.project,
|
|
63
|
-
phase,
|
|
64
|
-
});
|
|
65
|
-
} catch {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
return {
|
|
70
|
-
vendor: props.vendor,
|
|
71
|
-
project: props.project,
|
|
72
|
-
histories,
|
|
73
|
-
analyze: await snapshots("analyze"),
|
|
74
|
-
database: await snapshots("database"),
|
|
75
|
-
interface: await snapshots("interface"),
|
|
76
|
-
test: await snapshots("test"),
|
|
77
|
-
realize: await snapshots("realize"),
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const getSummary = async (props: {
|
|
82
|
-
vendor: string;
|
|
83
|
-
project: AutoBeExampleProject;
|
|
84
|
-
}): Promise<IAutoBePlaygroundReplay.ISummary | null> => {
|
|
85
|
-
const location: string = `${AutoBeExampleStorage.getDirectory(props)}/summary.json.gz`;
|
|
86
|
-
if (fs.existsSync(location) === false) return null;
|
|
87
|
-
const replay: IAutoBePlaygroundReplay.ISummary = JSON.parse(
|
|
88
|
-
await CompressUtil.gunzip(await fs.promises.readFile(location)),
|
|
89
|
-
);
|
|
90
|
-
return replay;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const getHistories = async (props: {
|
|
94
|
-
vendor: string;
|
|
95
|
-
project: AutoBeExampleProject;
|
|
96
|
-
}): Promise<AutoBeHistory[] | null> => {
|
|
97
|
-
for (const phase of SEQUENCE) {
|
|
98
|
-
try {
|
|
99
|
-
return await AutoBeExampleStorage.getHistories({
|
|
100
|
-
vendor: props.vendor,
|
|
101
|
-
project: props.project,
|
|
102
|
-
phase,
|
|
103
|
-
});
|
|
104
|
-
} catch {}
|
|
105
|
-
}
|
|
106
|
-
return null;
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const SEQUENCE = [
|
|
111
|
-
"realize",
|
|
112
|
-
"test",
|
|
113
|
-
"interface",
|
|
114
|
-
"database",
|
|
115
|
-
"analyze",
|
|
116
|
-
] as const;
|
|
1
|
+
import { CompressUtil } from "@autobe/filesystem";
|
|
2
|
+
import {
|
|
3
|
+
AutoBeEventSnapshot,
|
|
4
|
+
AutoBeExampleProject,
|
|
5
|
+
AutoBeHistory,
|
|
6
|
+
AutoBePhase,
|
|
7
|
+
IAutoBePlaygroundReplay,
|
|
8
|
+
} from "@autobe/interface";
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import typia from "typia";
|
|
11
|
+
|
|
12
|
+
import { AutoBeExampleStorage } from "../example/AutoBeExampleStorage";
|
|
13
|
+
|
|
14
|
+
export namespace AutoBeReplayStorage {
|
|
15
|
+
export const getAll = async (
|
|
16
|
+
vendor: string,
|
|
17
|
+
projectFilter?: (project: AutoBeExampleProject) => boolean,
|
|
18
|
+
): Promise<IAutoBePlaygroundReplay[]> => {
|
|
19
|
+
const projects: AutoBeExampleProject[] = typia.misc
|
|
20
|
+
.literals<AutoBeExampleProject>()
|
|
21
|
+
.filter(projectFilter ?? (() => true));
|
|
22
|
+
const replays: Array<IAutoBePlaygroundReplay | null> = await Promise.all(
|
|
23
|
+
projects.map((p) =>
|
|
24
|
+
AutoBeReplayStorage.get({
|
|
25
|
+
vendor,
|
|
26
|
+
project: p,
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
29
|
+
);
|
|
30
|
+
return replays.filter((r) => r !== null);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const getAllSummaries = async (
|
|
34
|
+
vendor: string,
|
|
35
|
+
projectFilter?: (project: AutoBeExampleProject) => boolean,
|
|
36
|
+
): Promise<IAutoBePlaygroundReplay.ISummary[]> => {
|
|
37
|
+
const projects: AutoBeExampleProject[] = typia.misc
|
|
38
|
+
.literals<AutoBeExampleProject>()
|
|
39
|
+
.filter(projectFilter ?? (() => true));
|
|
40
|
+
const summaries: Array<IAutoBePlaygroundReplay.ISummary | null> =
|
|
41
|
+
await Promise.all(
|
|
42
|
+
projects.map((project) =>
|
|
43
|
+
AutoBeReplayStorage.getSummary({ vendor, project }),
|
|
44
|
+
),
|
|
45
|
+
);
|
|
46
|
+
return summaries.filter((s) => s !== null);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const get = async (props: {
|
|
50
|
+
vendor: string;
|
|
51
|
+
project: AutoBeExampleProject;
|
|
52
|
+
}): Promise<IAutoBePlaygroundReplay | null> => {
|
|
53
|
+
const histories: AutoBeHistory[] | null = await getHistories(props);
|
|
54
|
+
if (histories === null) return null;
|
|
55
|
+
|
|
56
|
+
const snapshots = async (
|
|
57
|
+
phase: AutoBePhase,
|
|
58
|
+
): Promise<AutoBeEventSnapshot[] | null> => {
|
|
59
|
+
try {
|
|
60
|
+
return await AutoBeExampleStorage.getSnapshots({
|
|
61
|
+
vendor: props.vendor,
|
|
62
|
+
project: props.project,
|
|
63
|
+
phase,
|
|
64
|
+
});
|
|
65
|
+
} catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
vendor: props.vendor,
|
|
71
|
+
project: props.project,
|
|
72
|
+
histories,
|
|
73
|
+
analyze: await snapshots("analyze"),
|
|
74
|
+
database: await snapshots("database"),
|
|
75
|
+
interface: await snapshots("interface"),
|
|
76
|
+
test: await snapshots("test"),
|
|
77
|
+
realize: await snapshots("realize"),
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const getSummary = async (props: {
|
|
82
|
+
vendor: string;
|
|
83
|
+
project: AutoBeExampleProject;
|
|
84
|
+
}): Promise<IAutoBePlaygroundReplay.ISummary | null> => {
|
|
85
|
+
const location: string = `${AutoBeExampleStorage.getDirectory(props)}/summary.json.gz`;
|
|
86
|
+
if (fs.existsSync(location) === false) return null;
|
|
87
|
+
const replay: IAutoBePlaygroundReplay.ISummary = JSON.parse(
|
|
88
|
+
await CompressUtil.gunzip(await fs.promises.readFile(location)),
|
|
89
|
+
);
|
|
90
|
+
return replay;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const getHistories = async (props: {
|
|
94
|
+
vendor: string;
|
|
95
|
+
project: AutoBeExampleProject;
|
|
96
|
+
}): Promise<AutoBeHistory[] | null> => {
|
|
97
|
+
for (const phase of SEQUENCE) {
|
|
98
|
+
try {
|
|
99
|
+
return await AutoBeExampleStorage.getHistories({
|
|
100
|
+
vendor: props.vendor,
|
|
101
|
+
project: props.project,
|
|
102
|
+
phase,
|
|
103
|
+
});
|
|
104
|
+
} catch {}
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const SEQUENCE = [
|
|
111
|
+
"realize",
|
|
112
|
+
"test",
|
|
113
|
+
"interface",
|
|
114
|
+
"database",
|
|
115
|
+
"analyze",
|
|
116
|
+
] as const;
|
package/src/replay/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./AutoBeReplayComputer";
|
|
2
|
-
export * from "./AutoBeReplayDocumentation";
|
|
3
|
-
export * from "./AutoBeReplayStorage";
|
|
1
|
+
export * from "./AutoBeReplayComputer";
|
|
2
|
+
export * from "./AutoBeReplayDocumentation";
|
|
3
|
+
export * from "./AutoBeReplayStorage";
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AutoBeEventSnapshot,
|
|
3
|
-
AutoBeExampleProject,
|
|
4
|
-
AutoBePhase,
|
|
5
|
-
} from "@autobe/interface";
|
|
6
|
-
|
|
7
|
-
export interface IAutoBeExampleBenchmarkState {
|
|
8
|
-
vendors: IAutoBeExampleBenchmarkState.IOfVendor[];
|
|
9
|
-
}
|
|
10
|
-
export namespace IAutoBeExampleBenchmarkState {
|
|
11
|
-
export interface IOfVendor {
|
|
12
|
-
name: string;
|
|
13
|
-
projects: IOfProject[];
|
|
14
|
-
}
|
|
15
|
-
export interface IOfProject {
|
|
16
|
-
name: AutoBeExampleProject;
|
|
17
|
-
phases: IOfPhase[];
|
|
18
|
-
success: boolean | null;
|
|
19
|
-
started_at: Date | null;
|
|
20
|
-
completed_at: Date | null;
|
|
21
|
-
}
|
|
22
|
-
export interface IOfPhase {
|
|
23
|
-
name: AutoBePhase;
|
|
24
|
-
snapshot: AutoBeEventSnapshot | null;
|
|
25
|
-
success: boolean | null;
|
|
26
|
-
started_at: Date;
|
|
27
|
-
completed_at: Date | null;
|
|
28
|
-
count: number;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
AutoBeEventSnapshot,
|
|
3
|
+
AutoBeExampleProject,
|
|
4
|
+
AutoBePhase,
|
|
5
|
+
} from "@autobe/interface";
|
|
6
|
+
|
|
7
|
+
export interface IAutoBeExampleBenchmarkState {
|
|
8
|
+
vendors: IAutoBeExampleBenchmarkState.IOfVendor[];
|
|
9
|
+
}
|
|
10
|
+
export namespace IAutoBeExampleBenchmarkState {
|
|
11
|
+
export interface IOfVendor {
|
|
12
|
+
name: string;
|
|
13
|
+
projects: IOfProject[];
|
|
14
|
+
}
|
|
15
|
+
export interface IOfProject {
|
|
16
|
+
name: AutoBeExampleProject;
|
|
17
|
+
phases: IOfPhase[];
|
|
18
|
+
success: boolean | null;
|
|
19
|
+
started_at: Date | null;
|
|
20
|
+
completed_at: Date | null;
|
|
21
|
+
}
|
|
22
|
+
export interface IOfPhase {
|
|
23
|
+
name: AutoBePhase;
|
|
24
|
+
snapshot: AutoBeEventSnapshot | null;
|
|
25
|
+
success: boolean | null;
|
|
26
|
+
started_at: Date;
|
|
27
|
+
completed_at: Date | null;
|
|
28
|
+
count: number;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/structures/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./IAutoBeExampleBenchmarkState";
|
|
1
|
+
export * from "./IAutoBeExampleBenchmarkState";
|