Skip to content

Commit 64b5efc

Browse files
RandomBytewerwolf2303
authored andcommitted
ci: Allow for more hyperfine options, env variables
1 parent c02266f commit 64b5efc

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

internal/benchmark/lib/benchmark/BenchmarkSpec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ export default class BenchmarkSpec {
66
/**
77
* @param {object} config - The benchmark configuration object
88
* @param {string} config.command - The UI5 CLI command to benchmark (e.g., "build")
9+
* @param {string} [config.env] - Optional environment variables to prefix the command with
910
* @param {string} [config.prepare] - Optional shell command to run before each benchmark
11+
* @param {string} [config.conclude] - Optional shell command to run after each benchmark
1012
* @param {object} config.groups - Map of group keys to group-specific config
1113
* @param {string} config.groups[].name - Display name for this benchmark in the group
1214
* @param {string[]} [config.revisions] - Optional list of revision keys this benchmark should run on
@@ -19,9 +21,15 @@ export default class BenchmarkSpec {
1921
if (!config.command || typeof config.command !== "string") {
2022
throw new Error("Benchmark must have a command string");
2123
}
24+
if (config.env !== undefined && typeof config.env !== "string") {
25+
throw new Error("Benchmark env must be a string if provided");
26+
}
2227
if (config.prepare !== undefined && typeof config.prepare !== "string") {
2328
throw new Error("Benchmark prepare must be a string if provided");
2429
}
30+
if (config.conclude !== undefined && typeof config.conclude !== "string") {
31+
throw new Error("Benchmark conclude must be a string if provided");
32+
}
2533
if (!config.groups || typeof config.groups !== "object" || Object.keys(config.groups).length === 0) {
2634
throw new Error("Benchmark must belong to at least one group");
2735
}
@@ -53,14 +61,18 @@ export default class BenchmarkSpec {
5361

5462
this.#index = index;
5563
this.#command = config.command;
64+
this.#env = config.env || null;
5665
this.#prepare = config.prepare || null;
66+
this.#conclude = config.conclude || null;
5767
this.#groupMemberships = new Map(Object.entries(config.groups));
5868
this.#revisionKeys = config.revisions ? [...config.revisions] : null;
5969
}
6070

6171
#index;
6272
#command;
73+
#env;
6374
#prepare;
75+
#conclude;
6476
#groupMemberships; // Map<groupKey, {name: displayName}>
6577
#revisionKeys; // null means all revisions, otherwise array of revision keys
6678

@@ -72,10 +84,18 @@ export default class BenchmarkSpec {
7284
return this.#command;
7385
}
7486

87+
get env() {
88+
return this.#env;
89+
}
90+
7591
get prepare() {
7692
return this.#prepare;
7793
}
7894

95+
get conclude() {
96+
return this.#conclude;
97+
}
98+
7999
get groupMemberships() {
80100
return new Map(this.#groupMemberships);
81101
}

internal/benchmark/lib/services/ExecutionPlanner.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export default class ExecutionPlanner {
2424
* BenchmarkExecution = {
2525
* index: number,
2626
* command: string,
27+
* env: string|null,
2728
* prepare: string|null,
29+
* conclude: string|null,
2830
* groupMemberships: Array<{groupKey: string, displayName: string}>
2931
* }
3032
*/
@@ -58,7 +60,9 @@ export default class ExecutionPlanner {
5860
revisionPlan.benchmarks.push({
5961
index: benchmark.index,
6062
command: benchmark.command,
63+
env: benchmark.env,
6164
prepare: benchmark.prepare,
65+
conclude: benchmark.conclude,
6266
groupMemberships
6367
});
6468
}
@@ -96,9 +100,15 @@ export default class ExecutionPlanner {
96100
.map((gm) => `${gm.groupKey}: "${gm.displayName}"`)
97101
.join(", ");
98102
summary += ` [${benchmark.index}] ui5 ${benchmark.command}`;
103+
if (benchmark.env) {
104+
summary += ` [env: ${benchmark.env}]`;
105+
}
99106
if (benchmark.prepare) {
100107
summary += ` (prepare: ${benchmark.prepare})`;
101108
}
109+
if (benchmark.conclude) {
110+
summary += ` (conclude: ${benchmark.conclude})`;
111+
}
102112
summary += `\n Groups: ${groupNames}\n`;
103113
}
104114
}

internal/benchmark/lib/services/HyperfineRunner.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,16 @@ export default class HyperfineRunner {
6666
// Add each benchmark as a separate command to hyperfine
6767
for (const benchmark of benchmarks) {
6868
const commandName = this.#buildCommandName(name, revisionKey, benchmark);
69-
const fullCommand = `node ${this.#ui5CliPath} ${benchmark.command}`;
69+
let env = "";
70+
if (benchmark.env) {
71+
env += `${benchmark.env} `;
72+
}
73+
const fullCommand = `${env}node ${this.#ui5CliPath} ${benchmark.command}`;
7074

7175
// Add prepare command (empty string if none)
7276
args.push("--prepare", benchmark.prepare || "");
77+
// Add conclude command (empty string if none)
78+
args.push("--conclude", benchmark.conclude || "");
7379

7480
// Add the benchmark command
7581
args.push("--command-name", commandName, fullCommand);

0 commit comments

Comments
 (0)