Skip to content

Commit

Permalink
http-lib: use let@ for perf testing of the client
Browse files Browse the repository at this point in the history
No functional difference

Signed-off-by: Pau Ruiz Safont <[email protected]>
  • Loading branch information
psafont committed Oct 9, 2024
1 parent d8bd9f2 commit cda6194
Showing 1 changed file with 21 additions and 31 deletions.
52 changes: 21 additions & 31 deletions ocaml/libs/http-lib/test_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,59 +111,51 @@ let sample n f =
done ;
!p

let ( let@ ) f x = f x

let perf () =
let use_fastpath = !use_fastpath in
let use_framing = !use_framing in
let transport = if !use_ssl then with_stunnel else with_connection in
Printf.printf "1 thread non-persistent connections: " ;
let nonpersistent =
sample 1 (fun () ->
per_nsec 1. (fun () ->
transport !ip !port (one ~use_fastpath ~use_framing false)
)
)
let@ () = sample 1 in
let@ () = per_nsec 1. in
transport !ip !port (one ~use_fastpath ~use_framing false)
in
Printf.printf "%s RPCs/sec\n%!" (Normal_population.to_string nonpersistent) ;
Printf.printf "1 thread non-persistent connections (query): " ;
let nonpersistent_query =
sample 1 (fun () ->
per_nsec 1. (fun () ->
transport !ip !port (query ~use_fastpath ~use_framing false)
)
)
let@ () = sample 1 in
let@ () = per_nsec 1. in
transport !ip !port (query ~use_fastpath ~use_framing false)
in
Printf.printf "%s RPCs/sec\n%!"
(Normal_population.to_string nonpersistent_query) ;
Printf.printf "10 threads non-persistent connections: " ;
let thread_nonpersistent =
sample 1 (fun () ->
threads 10 (fun () ->
per_nsec 5. (fun () ->
transport !ip !port (one ~use_fastpath ~use_framing false)
)
)
)
let@ () = sample 1 in
let@ () = threads 10 in
let@ () = per_nsec 5. in
transport !ip !port (one ~use_fastpath ~use_framing false)
in
Printf.printf "%s RPCs/sec\n%!"
(Normal_population.to_string thread_nonpersistent) ;
Printf.printf "1 thread persistent connection: " ;
let persistent =
sample 1 (fun () ->
transport !ip !port (fun s ->
per_nsec 1. (fun () -> one ~use_fastpath ~use_framing true s)
)
)
let@ () = sample 1 in
let@ s = transport !ip !port in
let@ () = per_nsec 1. in
one ~use_fastpath ~use_framing true s
in
Printf.printf "%s RPCs/sec\n%!" (Normal_population.to_string persistent) ;
Printf.printf "10 threads persistent connections: " ;
let thread_persistent =
sample 1 (fun () ->
threads 10 (fun () ->
transport !ip !port (fun s ->
per_nsec 5. (fun () -> one ~use_fastpath ~use_framing true s)
)
)
)
let@ () = sample 1 in
let@ () = threads 10 in
let@ s = transport !ip !port in
let@ () = per_nsec 5. in
one ~use_fastpath ~use_framing true s
in
Printf.printf "%s RPCs/sec\n%!" (Normal_population.to_string thread_persistent)

Expand All @@ -187,8 +179,6 @@ let send_close_conn ~use_fastpath ~use_framing keep_alive s =
let bt = Backtrace.get e in
Debug.log_backtrace e bt

let ( let@ ) f x = f x

let logerr () =
(* Send a request to the server to close connection instead of replying with
an http request, force the error to be logged *)
Expand Down

0 comments on commit cda6194

Please sign in to comment.