mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-10 05:03:58 -05:00
more test
This commit is contained in:
parent
73c2f9768c
commit
3bfc4cdcc7
1 changed files with 18 additions and 10 deletions
|
|
@ -8,18 +8,20 @@ let sleep_for f () =
|
|||
let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "sleep" in
|
||||
Thread.delay f
|
||||
|
||||
let () =
|
||||
let@ () = Trace_tef.with_setup () in
|
||||
let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "main" in
|
||||
let run ~kind () =
|
||||
let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "run" in
|
||||
|
||||
let pool =
|
||||
Pool.create ~min:3
|
||||
~on_init_thread:(fun ~dom_id:_ ~t_id () ->
|
||||
Trace.set_thread_name (Printf.sprintf "pool worker %d" t_id))
|
||||
~around_task:
|
||||
( (fun self -> Trace.counter_int "n_tasks" (Pool.num_tasks self)),
|
||||
fun self () -> Trace.counter_int "n_tasks" (Pool.num_tasks self) )
|
||||
()
|
||||
let on_init_thread ~dom_id:_ ~t_id () =
|
||||
Trace.set_thread_name (Printf.sprintf "pool worker %d" t_id)
|
||||
and around_task =
|
||||
( (fun self -> Trace.counter_int "n_tasks" (Pool.num_tasks self)),
|
||||
fun self () -> Trace.counter_int "n_tasks" (Pool.num_tasks self) )
|
||||
in
|
||||
|
||||
match kind with
|
||||
| `Simple -> Simple_pool.create ~min:3 ~on_init_thread ~around_task ()
|
||||
| `Pool -> Pool.create ~min:3 ~on_init_thread ~around_task ()
|
||||
in
|
||||
|
||||
(* make all threads busy *)
|
||||
|
|
@ -42,3 +44,9 @@ let () =
|
|||
|
||||
let elapsed = Unix.gettimeofday () -. t in
|
||||
Printf.printf "elapsed: %.4fs\n%!" elapsed
|
||||
|
||||
let () =
|
||||
let@ () = Trace_tef.with_setup () in
|
||||
let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "main" in
|
||||
run ~kind:`Simple ();
|
||||
run ~kind:`Pool ()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue