diff --git a/README.md b/README.md index 3b0a270a..33a5d3ab 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ The name of this repository is a pun on two meanings of "time to": "how much tim | C (optimized, 16 threads) | 5ms | 249 | | squiggle.c | 37ms | 54 | | Nim | 38ms | 84 | -| OCaml | 42ms | 112 | | Lua (LuaJIT) | 68ms | 82 | +| OCaml (flambda mode) | 245ms | 112 | | Lua | 278ms | 82 | | C (naïve implementation) | 292ms | 149 | | Javascript (NodeJS) | 732ms | 69 | diff --git a/nim/samples b/nim/samples index 17b5420a..372f704e 100755 Binary files a/nim/samples and b/nim/samples differ diff --git a/ocaml/makefile b/ocaml/makefile index 2f5407c3..78edcbc1 100644 --- a/ocaml/makefile +++ b/ocaml/makefile @@ -1,18 +1,30 @@ # Compiler -CC=ocamlopt +OC=ocamlopt # ocamlopt: platform-specific, faster # ocamlc: platform-independent intermediate representation, run with ocamlrun +FAST=-O3 -unsafe # install flambda with opam -# Main file SRC=samples.ml OUT=./out/samples build: $(SRC) - $(CC) $(SRC) -o $(OUT) + $(OC) $(SRC) -o $(OUT) mv samples.cmi samples.cmx samples.o ./out/ run: $(OUT) +fast: + $(OC) $(FAST) $(SRC) -o $(OUT) + mv samples.cmi samples.cmx samples.o ./out/ + time: bash -c "time $(OUT)" + +switch-opam-fast: + opam switch create 4.11.2+flambda + eval $(opam env) + +switch-opam-5.1.0: + opam switch create 5.1.0 + eval $(opam env) diff --git a/ocaml/out/samples b/ocaml/out/samples index f23bec4e..b0583db9 100755 Binary files a/ocaml/out/samples and b/ocaml/out/samples differ diff --git a/ocaml/out/samples.cmi b/ocaml/out/samples.cmi index 67a0c682..1e08142f 100644 Binary files a/ocaml/out/samples.cmi and b/ocaml/out/samples.cmi differ diff --git a/ocaml/out/samples.cmx b/ocaml/out/samples.cmx index 4065573b..9c64b036 100644 Binary files a/ocaml/out/samples.cmx and b/ocaml/out/samples.cmx differ diff --git a/ocaml/out/samples.o b/ocaml/out/samples.o index df7a9bd0..bb7fa6ad 100644 Binary files a/ocaml/out/samples.o and b/ocaml/out/samples.o differ diff --git a/time.txt b/time.txt index 6c4cdcbc..74d978df 100644 --- a/time.txt +++ b/time.txt @@ -140,14 +140,12 @@ Time using 1 thread: 37.60ms ## squiggle.ml -— make build && make time -ocamlopt samples.ml -o ./out/samples +— make fast && make time +ocamlopt -O3 -unsafe samples.ml -o ./out/samples mv samples.cmi samples.cmx samples.o ./out/ bash -c "time ./out/samples" -Mean: 0.884629 +Mean: 0.886498 -real 0m0.425s -user 0m0.393s -sys 0m0.032s - -42ms +real 0m0.245s +user 0m0.232s +sys 0m0.012s