update benchs

This commit is contained in:
Simon Cruanes 2021-09-27 20:43:05 -04:00
parent 475e7b181e
commit 2c7e907061
No known key found for this signature in database
GPG key ID: 4AC01D0849AA62B6

View file

@ -79,19 +79,27 @@ module L = struct
else if x mod 5 = 1 then CCRAL.of_list [x;x+1] else if x mod 5 = 1 then CCRAL.of_list [x;x+1]
else CCRAL.of_list [x;x+1;x+2;x+3] else CCRAL.of_list [x;x+1;x+2;x+3]
let f_sek_ x =
if x mod 10 = 0 then Sek.Persistent.create 0
else if x mod 5 = 1 then Sek.Persistent.of_list 0 [x;x+1]
else Sek.Persistent.of_list 0 [x;x+1;x+2;x+3]
let bench_flat_map ?(time=2) n = let bench_flat_map ?(time=2) n =
let l = CCList.(1 -- n) in let l = CCList.(1 -- n) in
let ral = CCRAL.of_list l in let ral = CCRAL.of_list l in
let sek = Sek.Persistent.of_list 0 l in
let flatten_map_ l () = ignore @@ List.flatten (CCList.map f_ l) let flatten_map_ l () = ignore @@ List.flatten (CCList.map f_ l)
and flatmap l () = ignore @@ CCList.flat_map f_ l and flatmap l () = ignore @@ CCList.flat_map f_ l
and flatten_ccmap_ l () = ignore @@ List.flatten (List.map f_ l) and flatten_ccmap_ l () = ignore @@ List.flatten (List.map f_ l)
and flatmap_ral_ l () = ignore @@ CCRAL.flat_map f_ral_ l and flatmap_ral_ l () = ignore @@ CCRAL.flat_map f_ral_ l
and flatmap_sek s () = ignore @@ Sek.Persistent.flatten_map 0 f_sek_ s
in in
B.throughputN time ~repeat B.throughputN time ~repeat
[ "flat_map", flatmap l, () [ "flat_map", flatmap l, ()
; "flatten o CCList.map", flatten_ccmap_ l, () ; "flatten o CCList.map", flatten_ccmap_ l, ()
; "flatten o map", flatten_map_ l, () ; "flatten o map", flatten_map_ l, ()
; "ral_flatmap", flatmap_ral_ ral, () ; "ral_flatmap", flatmap_ral_ ral, ()
; "sek_flatmap", flatmap_sek sek, ()
] ]
(* APPEND *) (* APPEND *)
@ -123,21 +131,26 @@ module L = struct
(* FLATTEN *) (* FLATTEN *)
let bench_flatten ?(time=2) n = let bench_flatten ?(time=2) n =
let fold_right_append_ l = let fold_right_append_ l () =
List.fold_right List.append l [] ignore (List.fold_right List.append l [] : _ list)
and cc_fold_right_append_ l = and cc_fold_right_append_ l () =
CCList.fold_right CCList.append l [] ignore (CCList.fold_right CCList.append l [] : _ list)
and sek_flatten s () =
ignore (Sek.Persistent.flatten s : _ Sek.Persistent.t)
in in
let l = let l =
CCList.mapi CCList.mapi
(fun i x -> CCList.(x -- (x+ min i 100))) (fun i x -> CCList.(x -- (x+ min i 100)))
CCList.(1 -- n) CCList.(1 -- n)
in in
let sek = Sek.Persistent.of_list (Sek.Persistent.create 0)
(List.map (Sek.Persistent.of_list 0) l) in
B.throughputN time ~repeat B.throughputN time ~repeat
[ "CCList.flatten", CCList.flatten, l [ "CCList.flatten", (fun() -> ignore (CCList.flatten l)), ()
; "List.flatten", List.flatten, l ; "List.flatten", (fun() -> ignore (List.flatten l)), ()
; "fold_right append", fold_right_append_, l ; "fold_right append", fold_right_append_ l, ()
; "CCList.(fold_right append)", cc_fold_right_append_, l ; "CCList.(fold_right append)", cc_fold_right_append_ l, ()
; "Sek.flatten", sek_flatten sek, ()
] ]
(* RANDOM ACCESS *) (* RANDOM ACCESS *)