mirror of
https://github.com/c-cube/iter.git
synced 2025-12-06 03:05:29 -05:00
chore: repair build of benchmarks, fix warnings
This commit is contained in:
parent
97d4ac78a5
commit
1150098cd2
7 changed files with 35 additions and 30 deletions
9
Makefile
9
Makefile
|
|
@ -13,10 +13,15 @@ clean:
|
|||
doc:
|
||||
@dune build @doc
|
||||
|
||||
BENCH_TARGETS=bench_persistent_read.exe bench_persistent.exe
|
||||
BENCH_TARGETS= benchs.exe bench_persistent_read.exe bench_persistent.exe
|
||||
|
||||
benchs:
|
||||
dune build $(addprefix bench/, $(BENCH_TARGETS))
|
||||
@for i in $(BENCH_TARGETS) ; do \
|
||||
echo "run benchmark $$i" ; \
|
||||
dune exec "src/bench/$$i" ; done
|
||||
|
||||
build-benchs:
|
||||
@dune build $(addprefix src/bench/, $(BENCH_TARGETS))
|
||||
|
||||
examples:
|
||||
dune build examples/test_sexpr.exe
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
(executables
|
||||
((names (bench_persistent_read bench_persistent))
|
||||
(libraries (sequence benchmark))
|
||||
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always))
|
||||
(ocamlopt_flags (:standard -O3 -color always
|
||||
-unbox-closures -unbox-closures-factor 20))
|
||||
))
|
||||
|
|
@ -93,21 +93,21 @@ let persistent_mlist seq =
|
|||
MList.to_seq l
|
||||
|
||||
let bench_mlist n =
|
||||
for i = 0 to 100 do
|
||||
let _ = persistent_mlist Sequence.(1 -- n) in
|
||||
for _i = 0 to 100 do
|
||||
let _ = persistent_mlist Iter.(1 -- n) in
|
||||
()
|
||||
done
|
||||
|
||||
let bench_naive n =
|
||||
for i = 0 to 100 do
|
||||
let l = Sequence.to_rev_list Sequence.(1 -- n) in
|
||||
let _ = Sequence.of_list (List.rev l) in
|
||||
for _i = 0 to 100 do
|
||||
let l = Iter.to_rev_list Iter.(1 -- n) in
|
||||
let _ = Iter.of_list (List.rev l) in
|
||||
()
|
||||
done
|
||||
|
||||
let bench_current n =
|
||||
for i = 0 to 100 do
|
||||
let _ = Sequence.persistent Sequence.(1 -- n) in
|
||||
for _i = 0 to 100 do
|
||||
let _ = Iter.persistent Iter.(1 -- n) in
|
||||
()
|
||||
done
|
||||
|
||||
|
|
@ -93,26 +93,26 @@ let persistent_mlist seq =
|
|||
MList.to_seq l
|
||||
|
||||
let bench_mlist n =
|
||||
persistent_mlist Sequence.(1 -- n)
|
||||
persistent_mlist Iter.(1 -- n)
|
||||
|
||||
let bench_list n =
|
||||
let l = Sequence.to_rev_list Sequence.(1 -- n) in
|
||||
Sequence.of_list (List.rev l)
|
||||
let l = Iter.to_rev_list Iter.(1 -- n) in
|
||||
Iter.of_list (List.rev l)
|
||||
|
||||
let bench_naive n =
|
||||
let s = Sequence.(1 -- n) in
|
||||
Sequence.iter ignore s ;
|
||||
let s = Iter.(1 -- n) in
|
||||
Iter.iter ignore s ;
|
||||
s
|
||||
|
||||
let bench_current n =
|
||||
Sequence.persistent Sequence.(1 -- n)
|
||||
Iter.persistent Iter.(1 -- n)
|
||||
|
||||
let bench_array n =
|
||||
let a = Sequence.to_array Sequence.(1 -- n) in
|
||||
Sequence.of_array a
|
||||
let a = Iter.to_array Iter.(1 -- n) in
|
||||
Iter.of_array a
|
||||
|
||||
let read s =
|
||||
Sequence.map (fun x -> x + 1) s
|
||||
Iter.map (fun x -> x + 1) s
|
||||
|
||||
let () =
|
||||
let bench_n n =
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
module S = Sequence
|
||||
open Sequence.Infix
|
||||
module S = Iter
|
||||
open Iter.Infix
|
||||
|
||||
let small = [10;20;50;100;500]
|
||||
let medium = small @ [1000;10_000;100_000]
|
||||
8
src/bench/dune
Normal file
8
src/bench/dune
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
(executables
|
||||
(names bench_persistent_read bench_persistent benchs)
|
||||
(libraries iter benchmark)
|
||||
(flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always)
|
||||
(ocamlopt_flags :standard -O3 -color always
|
||||
-unbox-closures -unbox-closures-factor 20)
|
||||
)
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
open Sequence.Infix
|
||||
open Iter.Infix
|
||||
|
||||
let _ =
|
||||
let n = int_of_string Sys.argv.(1) in
|
||||
let seq = 0 -- n in
|
||||
let start = Unix.gettimeofday () in
|
||||
seq |> Sequence.persistent |> Sequence.fold (+) 0 |> ignore;
|
||||
seq |> Iter.persistent |> Iter.fold (+) 0 |> ignore;
|
||||
let stop = Unix.gettimeofday () in
|
||||
Format.printf "iter on %d: %.4f@." n (stop -. start);
|
||||
()
|
||||
Loading…
Add table
Reference in a new issue