2022-09-19 20:56:46 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
import { SqProject } from "@quri/squiggle-lang";
|
|
|
|
import { measure } from "./lib.mjs";
|
|
|
|
|
2022-09-19 20:59:46 +00:00
|
|
|
const maxP = 3;
|
2022-09-19 20:56:46 +00:00
|
|
|
|
2022-09-19 21:26:19 +00:00
|
|
|
const sampleCount = process.env.SAMPLE_COUNT;
|
|
|
|
|
2022-09-19 20:56:46 +00:00
|
|
|
for (let p = 0; p <= maxP; p++) {
|
|
|
|
const size = Math.pow(10, p);
|
|
|
|
const project = SqProject.create();
|
2022-09-19 21:26:19 +00:00
|
|
|
if (sampleCount) {
|
|
|
|
project.setEnvironment({
|
|
|
|
sampleCount: Number(sampleCount),
|
|
|
|
xyPointLength: Number(sampleCount),
|
|
|
|
});
|
|
|
|
}
|
2022-09-19 20:56:46 +00:00
|
|
|
project.setSource(
|
|
|
|
"main",
|
|
|
|
`
|
2022-09-19 21:26:19 +00:00
|
|
|
List.upTo(1, ${size}) -> map(
|
|
|
|
{ |x| normal(x,2) -> SampleSet.fromDist -> PointSet.fromDist }
|
|
|
|
)->List.last
|
2022-09-19 20:56:46 +00:00
|
|
|
`
|
|
|
|
);
|
|
|
|
const time = measure(() => {
|
|
|
|
project.run("main");
|
|
|
|
});
|
2022-09-19 21:26:19 +00:00
|
|
|
const result = project.getResult("main");
|
|
|
|
if (result.tag != "Ok") {
|
|
|
|
throw new Error("Code failed: " + result.value.toString());
|
|
|
|
}
|
2022-09-19 20:56:46 +00:00
|
|
|
console.log(`1e${p}`, "\t", time);
|
|
|
|
}
|