Conversation
Collaborator
Author
|
We can load childProcess like this import createBenchEvent from "./event";
import { isESM, isNode, taskIdFromEnv } from "./utils";
import Bench from "./bench";
import Task from "./task";
let childProcess = null;
// in bench.ts
async run() {
this.dispatchEvent(createBenchEvent('start'));
const values: Task[] = [];
if (!isNode) {
for (const task of [...this._tasks.values()]) {
if (this.signal?.aborted) values.push(task);
else values.push(await task.run());
}
} else {
const taskId = taskIdFromEnv();
if (taskId !== -1) {
const task = this.getTask(taskId);
if (task) {
await task.run();
return JSON.stringify(task.result);
}
return [];
} else {
// @ts-ignore
childProcess ??= isESM ? await import('node:child_process') : require('node:child_process');
for (const task of [...this._tasks.values()]) {
const result = childProcess.execSync(`TINYBENCH_TASK_ID=${task.id} ${process.argv.join(' ')}`, { env: process.env });
task.result = JSON.parse(result.toString());
}
}
} |
Collaborator
Author
|
I cant get it to work properly. :D Maybe somebody else has to take over. |
Member
|
Do you consider the possibility that tasks can be added in a different order at each launch? |
sirenkovladd
approved these changes
Nov 5, 2023
Member
|
Any summary on this PR? |
Collaborator
|
@Uzlopak @sirenkovladd: I do not see the added value of having a |
jerome-benoit
added a commit
to jerome-benoit/tinybench
that referenced
this pull request
Oct 13, 2024
closes tinylibs#62 Signed-off-by: Jérôme Benoit <[email protected]>
This was referenced Oct 13, 2024
Collaborator
|
See #120 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.