janestreet / janestreet/core_bench
How to Compile using Dune?
- Dominant language
- OCaml
- Stars
- 57
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
The Readme file is awefully sparse in its description of how to use Dune to compile a test bench. To be honest, I'm not sure how we are supposed to do this. When I compile a simple file that contains:
```
open! Core
open! Ocaml_math
open! Float
open! Plot
open! Core_bench
let () =
let open Permute in
let copy_label = String.of_string
and values = [|
Perm_value.{ label = "A"; num = 3 };
Perm_value.{ label = "B"; num = 5 };
Perm_value.{ label = "C"; num = 2 };
Perm_value.{ label = "D"; num = 0 };
|]
in
Command_unix.run @@ Bench.make_command [
Bench.Test.create ~name:"random_perm_alt" @@ fun () ->
let num_perms = get_num_perms values in
let index = num_perms |> Int.of_float |> Random.int in
get_nth_permutation ~copy_label index values
|> Option.map ~f:Queue.to_list
|> Fn.const ();
Bench.Test.create ~name:"random_perm" @@ fun () ->
Sequence.of_list [ "A"; "A"; "A"; "B"; "B"; "B"; "B"; "B"; "C"; "C" ]
|> Permute.f
|> Sequence.to_list
|> Fn.const ();
```
and run the program using: `dune exec bin/main.exe` I only see output for the first test in the test list.
Can someone elaborate and explain how we should compile benchmarks using Dune?
Thanks
Contributor guide
Research direction
Start with the README and the benchmark entry point invoked by bin/main.exe. Reproduce the example with dune exec bin/main.exe and check how the test list is configured and displayed. Document the Dune commands and benchmark workflow, including what output should appear for both tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100