Fix review comments
This commit is contained in:
parent
fb5fd8edf8
commit
e8aa541fc9
|
@ -22,25 +22,10 @@ export const run = (src, { output, sampleCount } = {}) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
project.setSource("main", src);
|
project.setSource("main", src);
|
||||||
const time = measure(() => project.run("main"));
|
runProject(project, output);
|
||||||
|
|
||||||
const bindings = project.getBindings("main");
|
|
||||||
const result = project.getResult("main");
|
|
||||||
|
|
||||||
if (output) {
|
|
||||||
console.log("Result:", result.tag, result.value.toString());
|
|
||||||
console.log("Bindings:", bindings.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
"Time:",
|
|
||||||
String(time),
|
|
||||||
result.tag === "Error" ? red(result.tag) : green(result.tag),
|
|
||||||
result.tag === "Error" ? result.value.toStringWithFrameStack() : ""
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const runProject = (project, output) => {
|
export const runProject = (project, { output }) => {
|
||||||
const time = measure(() => project.runAll());
|
const time = measure(() => project.runAll());
|
||||||
console.log("Time: ", time);
|
console.log("Time: ", time);
|
||||||
|
|
||||||
|
@ -48,7 +33,7 @@ export const runProject = (project, output) => {
|
||||||
|
|
||||||
ids.forEach((id) => {
|
ids.forEach((id) => {
|
||||||
const result = project.getResult(id);
|
const result = project.getResult(id);
|
||||||
const bindings = project.getBindings("main");
|
const bindings = project.getBindings(id);
|
||||||
|
|
||||||
console.log(id + ":");
|
console.log(id + ":");
|
||||||
if (output) {
|
if (output) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ program.arguments("<string>");
|
||||||
|
|
||||||
const options = program.parse(process.argv);
|
const options = program.parse(process.argv);
|
||||||
|
|
||||||
const sampleCount = process.env.SAMPLE_COUNT ?? 10000;
|
const sampleCount = process.env.SAMPLE_COUNT;
|
||||||
console.log(sampleCount);
|
console.log(sampleCount);
|
||||||
|
|
||||||
const src = fs.readFileSync(program.args[0], "utf-8");
|
const src = fs.readFileSync(program.args[0], "utf-8");
|
||||||
|
@ -25,4 +25,4 @@ const projectJson = JSON.parse(src);
|
||||||
|
|
||||||
const project = SqProject.fromJson(projectJson);
|
const project = SqProject.fromJson(projectJson);
|
||||||
|
|
||||||
runProject(project, options.output);
|
runProject(project, options);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user