From a5e0da8cd420b22debb3e988b1a4156ca70b96b6 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sun, 19 Nov 2023 20:40:12 +0000 Subject: [PATCH] fix squiggle path to use correct method --- README.md | 6 +++--- squiggle/makefile | 3 --- squiggle/notes-monkeypatch.md | 7 ------- .../node_modules/@quri/squiggle-lang/dist/magicNumbers.js | 2 +- .../node_modules/@quri/squiggle-lang/src/magicNumbers.ts | 2 +- squiggle/src/samples.js | 8 +++++--- 6 files changed, 10 insertions(+), 18 deletions(-) delete mode 100644 squiggle/notes-monkeypatch.md diff --git a/README.md b/README.md index 7c21b712..64e20cfd 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The name of this repository is a pun on two meanings of "time to": "how much tim | Nim | 40.8ms | 84 | | Lua (LuaJIT) | 69.9ms | 82 | | OCaml (flambda) | 187.9ms | 123 | -| Squiggle (bun) | 0.386s | 14* | +| Squiggle (bun) | 0.538s | 14* | | Javascript (node) | 0.445s | 69 | | SquigglePy (v0.27) | 1.507s | 18* | | R (3.6.1) | 4.508s | 49 | @@ -85,9 +85,9 @@ I like the [operator](http://duskos.org/#operator) section of [Dusk OS](http://d ### NodeJS and Squiggle -Using [bun](https://bun.sh/) instead of node is actually a bit slower. Also, both the NodeJS and the Squiggle code use [stdlib](https://stdlib.io/) in their innards, which has a bunch of interleaved functions that make the code slower. It's possible that not using that external library could make the code faster. But at the same time, the js approach does seem to be to use external libraries whenever possible. +Using [bun](https://bun.sh/) instead of node is actually a bit slower for the raw js code. Also, both the NodeJS and the Squiggle code use [stdlib](https://stdlib.io/) in their innards, which has a bunch of interleaved functions that make the code slower. It's possible that not using that external library could make the code faster. But at the same time, the js approach does seem to be to use external libraries whenever possible. -I wasn't particularly sure that the Squiggle code was actually producing 1M samples, so I applied a [monkey patch](https://git.nunosempere.com/personal/time-to-botec/src/branch/master/squiggle/makefile#L14) to ensure this. In general, Squiggle tries to present a simple interface to the user, leading to "hiding the magic" and having a bunch of [bugs](https://github.com/quantified-uncertainty/squiggle/labels/Bug), whereas I think the right tradeoff for me is to have some simple interface that I can operate skillfully (i.e., squiggle.c). +In general, Squiggle tries to present a simple interface to the user, leading to "hiding the magic" and having a bunch of [bugs](https://github.com/quantified-uncertainty/squiggle/labels/Bug), whereas I think the right tradeoff for me is to have some simple interface that I can operate skillfully (i.e., squiggle.c). ### Python and Squigglepy diff --git a/squiggle/makefile b/squiggle/makefile index a202675c..92080d90 100644 --- a/squiggle/makefile +++ b/squiggle/makefile @@ -11,9 +11,6 @@ time-bun: run-bun: bun src/samples.js -patch: - sed -i 's/defaultSampleCount: 1000/defaultSampleCount: 1000000/g' src/node_modules/@quri/squiggle-lang/src/magicNumbers.ts src/node_modules/@quri/squiggle-lang/dist/magicNumbers.js - run-node: node src/samples.js diff --git a/squiggle/notes-monkeypatch.md b/squiggle/notes-monkeypatch.md deleted file mode 100644 index 6460ec15..00000000 --- a/squiggle/notes-monkeypatch.md +++ /dev/null @@ -1,7 +0,0 @@ -I can't currently figure out how to change the number of samples from within squiggle for mixtures, -so instead I monkey patched it - -- https://github.com/quantified-uncertainty/squiggle/issues/2560 -- grep -r . -e defaultSampleCount -- sed -i 's/defaultSampleCount: 1000/defaultSampleCount: 1000000/g' node_modules/@quri/squiggle-lang/src/magicNumbers.ts node_modules/@quri/squiggle-lang/dist/magicNumbers.js - diff --git a/squiggle/src/node_modules/@quri/squiggle-lang/dist/magicNumbers.js b/squiggle/src/node_modules/@quri/squiggle-lang/dist/magicNumbers.js index 8eb2728d..f6d9cffd 100644 --- a/squiggle/src/node_modules/@quri/squiggle-lang/dist/magicNumbers.js +++ b/squiggle/src/node_modules/@quri/squiggle-lang/dist/magicNumbers.js @@ -1,7 +1,7 @@ export const epsilon_float = 2.22044604925031308e-16; export const Environment = { defaultXYPointLength: 1000, - defaultSampleCount: 1000000, + defaultSampleCount: 1000, sparklineLength: 20, }; export const OpCost = { diff --git a/squiggle/src/node_modules/@quri/squiggle-lang/src/magicNumbers.ts b/squiggle/src/node_modules/@quri/squiggle-lang/src/magicNumbers.ts index 291e5d80..2af4edd9 100644 --- a/squiggle/src/node_modules/@quri/squiggle-lang/src/magicNumbers.ts +++ b/squiggle/src/node_modules/@quri/squiggle-lang/src/magicNumbers.ts @@ -2,7 +2,7 @@ export const epsilon_float = 2.22044604925031308e-16; // via pervasives.js export const Environment = { defaultXYPointLength: 1000, - defaultSampleCount: 1000000, + defaultSampleCount: 1000, sparklineLength: 20, }; diff --git a/squiggle/src/samples.js b/squiggle/src/samples.js index 2f35d4ed..d85cdc55 100644 --- a/squiggle/src/samples.js +++ b/squiggle/src/samples.js @@ -19,9 +19,11 @@ mean(result) async function main(){ let output = await run(squiggle_code, { - defaultXYPointLength: 1000000, - defaultSampleCount: 1000000, - sparklineLength: 20, + environment: { + xyPointLength: 1000000, + sampleCount: 1000000, + sparkLine: 20, + } }) console.log(output.value.result.value) }