var name cleanups

This commit is contained in:
Vyacheslav Matyukhin 2022-09-18 20:13:54 +04:00
parent 66d9cb0ab1
commit a77bb36219
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
3 changed files with 14 additions and 14 deletions

View File

@ -15,13 +15,13 @@ const maxP = 5;
for (let p = 0; p <= maxP; p++) {
const size = Math.pow(10, p);
const prj = SqProject.create();
prj.setSource(
const project = SqProject.create();
project.setSource(
"main",
`List.upTo(1, ${size}) |> map({|x| List.upTo(1, 100) |> reduce(0, {|a,b|a+b})})`
);
const t = measure(() => {
prj.run("main");
const time = measure(() => {
project.run("main");
});
console.log(`1e${p}`, "\t", t);
console.log(`1e${p}`, "\t", time);
}

View File

@ -14,8 +14,8 @@ const measure = (cb, times = 1) => {
return (t2 - t1) / 1000;
};
const red = (s) => `\x1b[31m${s}\x1b[0m`;
const green = (s) => `\x1b[32m${s}\x1b[0m`;
const red = (str) => `\x1b[31m${str}\x1b[0m`;
const green = (str) => `\x1b[32m${str}\x1b[0m`;
const program = new Command();
@ -39,7 +39,7 @@ if (!src) {
}
project.setSource("main", src);
const t = measure(() => project.run("main"));
const time = measure(() => project.run("main"));
const bindings = project.getBindings("main");
const result = project.getResult("main");
@ -51,7 +51,7 @@ if (options.output) {
console.log(
"Time:",
String(t),
String(time),
result.tag === "Error" ? red(result.tag) : green(result.tag),
result.tag === "Error" ? result.value.toString() : ""
);

View File

@ -1,18 +1,18 @@
#!/usr/bin/env node
import { SqProject } from "@quri/squiggle-lang";
const p = SqProject.create();
const project = SqProject.create();
const src = process.argv[2];
if (!src) {
throw new Error("Expected src");
}
console.log(`Running ${src}`);
p.setSource("a", src);
p.run("a");
project.setSource("a", src);
project.run("a");
const result = p.getResult("a");
const result = project.getResult("a");
console.log(result.tag, result.value.toString());
const bindings = p.getBindings("a");
const bindings = project.getBindings("a");
console.log(bindings.asValue().toString());