mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-25 08:00:59 +00:00
properly count steps of flows in benchmark (#4407)
* fix(benchmark): properly count steps of flows * signing commit --------- Co-authored-by: Alexander Petric <alex@inpher.io>
This commit is contained in:
@@ -106,6 +106,30 @@ export async function main({
|
||||
).database_length;
|
||||
}
|
||||
|
||||
async function getFlowStepCount(
|
||||
workspace: string,
|
||||
path: string
|
||||
): Promise<number> {
|
||||
const response = await fetch(
|
||||
`${config.server}/api/w/${workspace}/flows/get/${path}`,
|
||||
{ headers: { ["Authorization"]: "Bearer " + config.token } }
|
||||
);
|
||||
|
||||
const data = await response.json();
|
||||
let stepCount = 0;
|
||||
|
||||
for (const mod of data.value.modules) {
|
||||
if (mod.value.type === "flow" && mod.value.path) {
|
||||
const subFlowCount = await getFlowStepCount(workspace, mod.value.path);
|
||||
stepCount += subFlowCount;
|
||||
} else {
|
||||
stepCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return stepCount;
|
||||
}
|
||||
|
||||
let pastJobs = 0;
|
||||
async function getCompletedJobsCount(): Promise<number> {
|
||||
const completedJobs = (
|
||||
@@ -133,6 +157,7 @@ export async function main({
|
||||
console.log(`Bulk creating ${jobsSent} jobs`);
|
||||
|
||||
const start_create = Date.now();
|
||||
let nStepsFlow = 0;
|
||||
let body: string;
|
||||
if (kind === "noop") {
|
||||
body = JSON.stringify({
|
||||
@@ -148,6 +173,7 @@ export async function main({
|
||||
path: "f/benchmarks/" + kind,
|
||||
});
|
||||
} else if (["2steps"].includes(kind)) {
|
||||
nStepsFlow = 2;
|
||||
const payload = getFlowPayload(kind);
|
||||
body = JSON.stringify({
|
||||
kind: "flow",
|
||||
@@ -155,9 +181,12 @@ export async function main({
|
||||
});
|
||||
} else if (kind.startsWith("flow:")) {
|
||||
console.log("Detected custom flow ");
|
||||
let flow_path = kind.substr(5);
|
||||
nStepsFlow = await getFlowStepCount(config.workspace_id, flow_path);
|
||||
console.log(`Total steps of flow including sub-flows: ${nStepsFlow}`);
|
||||
body = JSON.stringify({
|
||||
kind: "flow",
|
||||
path: kind.substr(5),
|
||||
path: flow_path,
|
||||
});
|
||||
} else if (kind.startsWith("script:")) {
|
||||
console.log("Detected custom script");
|
||||
@@ -218,7 +247,7 @@ export async function main({
|
||||
const elapsed = start ? Date.now() - start : 0;
|
||||
completedJobs = await getCompletedJobsCount();
|
||||
if (kind === "2steps" || kind.startsWith("flow:")) {
|
||||
completedJobs = Math.floor(completedJobs / 3);
|
||||
completedJobs = Math.floor(completedJobs / (nStepsFlow + 1));
|
||||
}
|
||||
const avgThr = ((completedJobs / elapsed) * 1000).toFixed(2);
|
||||
const instThr =
|
||||
|
||||
Reference in New Issue
Block a user