Skip to content

Commit

Permalink
fix ocaml
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyus committed Oct 8, 2023
1 parent c0b2b0d commit 0113526
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ jobs:
with:
python-version: "3.11"

- name: Install Ocaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: "5.1"

- name: Run Benchmark
run: ./run.sh all raw_results.md

Expand Down
7 changes: 3 additions & 4 deletions ocaml/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ type related_posts =
type post_array = post array [@@deriving of_yojson]
type related_posts_array = related_posts array [@@deriving to_yojson]

let source = "../posts.json"
let destination = "../related_posts_ocaml.json"

let () =
let args = Sys.get_argv () in
Array.sexp_of_t String.sexp_of_t args |> Sexp.to_string |> Stdio.print_endline;
let source = args.(1) in
let destination = args.(2) in
let posts =
Yojson.Safe.from_file source |> post_array_of_yojson |> Result.ok_or_failwith
in
Expand Down
18 changes: 18 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,20 @@ run_lua() {
check_output "related_posts_lua.json"
}

run_ocaml() {
echo "Running Ocaml" &&
cd ./ocaml &&
opam install . --deps-only -y &&
opam exec -- dune build &&
if [ $HYPER == 1 ]; then
capture "ocaml" hyperfine -r 10 -w 3 --show-output "./_build/default/bin/main.exe"
else
command time -f '%es %Mk' ./_build/default/bin/main.exe
fi

check_output "related_posts_ocaml.json"
}

check_output() {
cd .. &&
echo "Checking output" &&
Expand Down Expand Up @@ -596,6 +610,10 @@ elif [ "$first_arg" = "lua" ]; then

run_lua

elif [ "$first_arg" = "ocaml" ]; then

run_ocaml

elif [ "$first_arg" = "all" ]; then

echo -e "Running all\n" &&
Expand Down

0 comments on commit 0113526

Please sign in to comment.