Skip to content

Commit

Permalink
Use List.init instead of create_for, move setup code out of critical …
Browse files Browse the repository at this point in the history
…path
  • Loading branch information
Cjen1 committed May 9, 2020
1 parent 9f43b56 commit 3bffb89
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions test-bin/echo/echo_bench.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ let () =
Logs.set_level (Some Logs.Info);
Logs.set_reporter (Logs_fmt.reporter ())

let rec create_for v = function
| 0. -> []
| n -> v n :: (create_for v (n-.1.))

let run_client service =
let n = 100000. in
let ops = n |> create_for (fun i ->
let n = 100000 in
let ops = List.init n (fun i ->
let payload = Int.to_string i in
let desired_result = "echo:" ^ payload in
fun () ->
Echo.ping service (Float.to_string i) >>= fun res ->
Lwt.return (res = "echo:" ^ (Float.to_string i))
Echo.ping service payload >>= fun res ->
Lwt.return (res = desired_result)
) in
let st = Unix.gettimeofday () in
Lwt_list.map_p (fun v -> v ()) ops >>= fun _ ->
let ed = Unix.gettimeofday () in
let rate = n /. (ed -. st) in
let rate = (Int.to_float n) /. (ed -. st) in
Logs.info (fun m -> m "rate = %f" rate );
Lwt.return_unit

Expand Down

0 comments on commit 3bffb89

Please sign in to comment.