Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in Core_bench interface? #37

Open
samrat opened this issue Jul 16, 2015 · 3 comments
Open

Change in Core_bench interface? #37

samrat opened this issue Jul 16, 2015 · 3 comments

Comments

@samrat
Copy link

samrat commented Jul 16, 2015

I'm trying to run the code in https://github.com/realworldocaml/examples/blob/master/code/lists-and-patterns/main.topscript#L62. However, it looks like the type signature of Bench.bench has changed since the example was written:

utop[6]> #require "core_bench";;
utop[7]> open Core_bench.Std;;
utop[8]> Bench.bench;;
- : ?run_config:Bench.Run_config.t ->
    ?analysis_configs:Bench.Analysis_config.t list ->
    ?display_config:Bench.Display_config.t ->
    ?save_to_file:(Bench.Measurement.t -> bytes) ->
    Core_bench.Test.t list -> unit
= <fun>
utop[9]> let run_bench tests =
  Bench.bench
    ~ascii_table:true
    ~display:Textutils.Ascii_table.Display.column_titles
    tests
;;
Error: The function applied to this argument has type
         ?run_config:Bench.Run_config.t ->
         ?analysis_configs:Bench.Analysis_config.t list ->
         ?display_config:Bench.Display_config.t ->
         ?save_to_file:(Bench.Measurement.t -> bytes) -> unit
This argument cannot be applied with label ~ascii_table
utop[10]> 

The core_bench version I have installed is 112.35.00

@samrat
Copy link
Author

samrat commented Jul 22, 2015

I believe this is what the run_bench function should look like:

let run_bench tests =
           Command.run (Bench.make_command tests);;

@seungjin
Copy link

seungjin commented Sep 8, 2015

What about this? :-)
Core_bench version: 109.58.01

let display_config = Bench.Display_config.create
                       ~display:Textutils.Ascii_table.Display.column_titles
                       ~ascii_table:true
                       ~show_percentage:true
                       ()
;;

let run_bench tests =
  Bench.bench
  ~display_config:display_config
  tests
;;

Also commented here: realworldocaml/book#2714

@zzhjerry
Copy link

zzhjerry commented Jun 6, 2016

If someone doesn't care about the display style, using Bench.bench is also fine.

[ Bench.Test.create ~name:"plus_one_match" (fun () ->
      ignore (plus_one_match 10))
  ; Bench.Test.create ~name:"plus_one_if" (fun () ->
      ignore (plus_one_if 10)) ]
  |> Bench.bench
  ;;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants