Skip to content

Commit

Permalink
Switched out the for loop for it.concurrent.for
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Dec 13, 2024
1 parent 2d91ca3 commit d9bea0c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/evalite-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"evalite": "workspace:*",
"strip-ansi": "^7.1.0",
"autoevals": "^0.0.108",
"@ai-sdk/openai": "^1.0.8",
"ai": "^4.0.11"
}
}
15 changes: 8 additions & 7 deletions packages/evalite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,17 @@ export const evalite = <TInput, TExpected = TInput>(
return describe(evalName, async () => {
const dataset = await opts.data();

for (const [order, data] of Object.entries(dataset)) {
it(`${evalName} ${order}`, { concurrent: true }, async ({ task }) => {
it.concurrent.for(dataset.map((d, index) => ({ ...d, index })))(
evalName,
async (data, { task }) => {
task.meta.evalite = {
duration: undefined,
initialResult: {
evalName: evalName,
filepath: task.file.filepath,
input: data.input,
expected: data.expected,
order: Number(order),
order: data.index,
},
};
const start = performance.now();
Expand All @@ -109,7 +110,7 @@ export const evalite = <TInput, TExpected = TInput>(
result: {
evalName: evalName,
filepath: task.file.filepath,
order: Number(order),
order: data.index,
duration,
expected: data.expected,
input: data.input,
Expand All @@ -125,7 +126,7 @@ export const evalite = <TInput, TExpected = TInput>(
result: {
evalName: evalName,
filepath: task.file.filepath,
order: Number(order),
order: data.index,
duration: Math.round(performance.now() - start),
expected: data.expected,
input: data.input,
Expand All @@ -138,8 +139,8 @@ export const evalite = <TInput, TExpected = TInput>(
};
throw e;
}
});
}
}
);
});
};

Expand Down
48 changes: 48 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d9bea0c

Please sign in to comment.