Skip to content

Commit 2c7e907

Browse files
committed
update benchs
1 parent 475e7b1 commit 2c7e907

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

benchs/run_benchs.ml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,27 @@ module L = struct
7979
else if x mod 5 = 1 then CCRAL.of_list [x;x+1]
8080
else CCRAL.of_list [x;x+1;x+2;x+3]
8181

82+
let f_sek_ x =
83+
if x mod 10 = 0 then Sek.Persistent.create 0
84+
else if x mod 5 = 1 then Sek.Persistent.of_list 0 [x;x+1]
85+
else Sek.Persistent.of_list 0 [x;x+1;x+2;x+3]
86+
8287
let bench_flat_map ?(time=2) n =
8388
let l = CCList.(1 -- n) in
8489
let ral = CCRAL.of_list l in
90+
let sek = Sek.Persistent.of_list 0 l in
8591
let flatten_map_ l () = ignore @@ List.flatten (CCList.map f_ l)
8692
and flatmap l () = ignore @@ CCList.flat_map f_ l
8793
and flatten_ccmap_ l () = ignore @@ List.flatten (List.map f_ l)
8894
and flatmap_ral_ l () = ignore @@ CCRAL.flat_map f_ral_ l
95+
and flatmap_sek s () = ignore @@ Sek.Persistent.flatten_map 0 f_sek_ s
8996
in
9097
B.throughputN time ~repeat
9198
[ "flat_map", flatmap l, ()
9299
; "flatten o CCList.map", flatten_ccmap_ l, ()
93100
; "flatten o map", flatten_map_ l, ()
94101
; "ral_flatmap", flatmap_ral_ ral, ()
102+
; "sek_flatmap", flatmap_sek sek, ()
95103
]
96104

97105
(* APPEND *)
@@ -123,21 +131,26 @@ module L = struct
123131
(* FLATTEN *)
124132

125133
let bench_flatten ?(time=2) n =
126-
let fold_right_append_ l =
127-
List.fold_right List.append l []
128-
and cc_fold_right_append_ l =
129-
CCList.fold_right CCList.append l []
134+
let fold_right_append_ l () =
135+
ignore (List.fold_right List.append l [] : _ list)
136+
and cc_fold_right_append_ l () =
137+
ignore (CCList.fold_right CCList.append l [] : _ list)
138+
and sek_flatten s () =
139+
ignore (Sek.Persistent.flatten s : _ Sek.Persistent.t)
130140
in
131141
let l =
132142
CCList.mapi
133143
(fun i x -> CCList.(x -- (x+ min i 100)))
134144
CCList.(1 -- n)
135145
in
146+
let sek = Sek.Persistent.of_list (Sek.Persistent.create 0)
147+
(List.map (Sek.Persistent.of_list 0) l) in
136148
B.throughputN time ~repeat
137-
[ "CCList.flatten", CCList.flatten, l
138-
; "List.flatten", List.flatten, l
139-
; "fold_right append", fold_right_append_, l
140-
; "CCList.(fold_right append)", cc_fold_right_append_, l
149+
[ "CCList.flatten", (fun() -> ignore (CCList.flatten l)), ()
150+
; "List.flatten", (fun() -> ignore (List.flatten l)), ()
151+
; "fold_right append", fold_right_append_ l, ()
152+
; "CCList.(fold_right append)", cc_fold_right_append_ l, ()
153+
; "Sek.flatten", sek_flatten sek, ()
141154
]
142155

143156
(* RANDOM ACCESS *)

0 commit comments

Comments
 (0)