squiggle/packages/squiggle-lang/scripts/bench-map-reduce.mjs

19 lines
452 B
JavaScript
Raw Permalink Normal View History

#!/usr/bin/env node
2022-09-18 15:18:10 +00:00
import { SqProject } from "@quri/squiggle-lang";
2022-09-19 20:55:32 +00:00
import { measure } from "./lib.mjs";
const maxP = 5;
for (let p = 0; p <= maxP; p++) {
const size = Math.pow(10, p);
2022-09-18 16:13:54 +00:00
const project = SqProject.create();
project.setSource(
"main",
`List.upTo(1, ${size}) |> map({|x| List.upTo(1, 100) |> reduce(0, {|a,b|a+b})})`
);
2022-09-18 16:13:54 +00:00
const time = measure(() => {
project.run("main");
});
2022-09-18 16:13:54 +00:00
console.log(`1e${p}`, "\t", time);
}