diff --git a/README.md b/README.md index b169ed74..3b0a270a 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ 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 | | Lua | 278ms | 82 | | C (naïve implementation) | 292ms | 149 | @@ -128,7 +129,7 @@ Overall I don't think that this is a fair comparison of the languages intrinsica - [ ] bc (the standard posix calculator) - [ ] Zig - [ ] Rust -- [ ] OCaml +- [x] OCaml - [ ] Forth - [ ] Julia (TuringML, MCHammer) - [ ] Lisp diff --git a/ocaml/makefile b/ocaml/makefile index 5ec1ec86..2f5407c3 100644 --- a/ocaml/makefile +++ b/ocaml/makefile @@ -5,10 +5,14 @@ CC=ocamlopt # Main file SRC=samples.ml +OUT=./out/samples build: $(SRC) - $(CC) $(SRC) -o out/samples + $(CC) $(SRC) -o $(OUT) mv samples.cmi samples.cmx samples.o ./out/ run: - ./out/samples + $(OUT) + +time: + bash -c "time $(OUT)" diff --git a/time.txt b/time.txt index 8e6d268a..6c4cdcbc 100644 --- a/time.txt +++ b/time.txt @@ -138,3 +138,16 @@ Requires /bin/time, found on GNU/Linux systems Running 100x and taking avg time example Time using 1 thread: 37.60ms +## squiggle.ml + +— make build && make time +ocamlopt samples.ml -o ./out/samples +mv samples.cmi samples.cmx samples.o ./out/ +bash -c "time ./out/samples" +Mean: 0.884629 + +real 0m0.425s +user 0m0.393s +sys 0m0.032s + +42ms