bench-sampleset-to-pointset.js (1041B)
1 #!/usr/bin/env node 2 import { SqProject } from "../index.js"; 3 import { measure } from "../cli/utils.js"; 4 const maxP = 4; 5 const sampleCount = process.env["SAMPLE_COUNT"]; 6 async function main() { 7 for (let p = 0; p <= maxP; p++) { 8 const size = Math.pow(10, p); 9 const project = SqProject.create(); 10 if (sampleCount) { 11 project.setEnvironment({ 12 sampleCount: Number(sampleCount), 13 xyPointLength: Number(sampleCount), 14 }); 15 } 16 project.setSource("main", ` 17 List.upTo(1, ${size}) -> map( 18 { |x| normal(x,2) -> SampleSet.fromDist -> PointSet.fromDist } 19 )->List.last 20 `); 21 const time = await measure(async () => { 22 await project.run("main"); 23 }); 24 const result = project.getResult("main"); 25 if (!result.ok) { 26 throw new Error("Code failed: " + result.value.toString()); 27 } 28 console.log(`1e${p}`, "\t", time); 29 } 30 } 31 main(); 32 //# sourceMappingURL=bench-sampleset-to-pointset.js.map