Commits

Sebastien Mondet  committed a90fab8

Add experiment enum_transform_counter_with_lines_of

  • Participants
  • Parent commits 94b129d

Comments (0)

Files changed (1)

File fastqbench.ml

 
 ocamlfind ocamlopt -thread -package lwt.unix,biocaml,core -linkpkg fastqbench.ml -o fastbench
 
+./fastbench 01.fastq | brtx -doc -o bench.html 
+
 *)
 
 open Core.Std
   let count = BatEnum.hard_count e / 4 in
   count
 
+let enum_transform_counter_with_lines_of  file =
+  let e = BatFile.lines_of file in
+  let e4buf = BatEnum.map  (sprintf "%s\n") e in
+  let tr = Biocaml_fastq.enum_parser ~filename:file  in
+  BatEnum.hard_count (tr e4buf)
+  
     
 let do_bench exp_name repetitions buffer_sizes files =
   Lwt_io.printf "{section|Benchmark %S}\n\
         bufs reads time (time /. float repetitions))
       lwt_io_results
     >>= fun () ->
-    let reads = ref 0 in
-    let rec iteration = function
-      | 0 -> return ()
-      | n -> reads := enum_read_counter file; iteration (n - 1) in
-    let start = Time.now () in
-    iteration repetitions >>= fun () ->
-    let time = Time.(diff (now ()) start) |! Core.Span.to_float in
-    Lwt_io.printf "{c|{t|File.lines_of |> Enum.hard_count / 4}} {c|%d} {c|%f (%f)}\n"
-      !reads time (time /. float repetitions)
+    let bench_non_lwt f name =
+      let reads = ref 0 in
+      let rec iteration = function
+        | 0 -> return ()
+        | n -> reads := f file; iteration (n - 1) in
+      let start = Time.now () in
+      iteration repetitions >>= fun () ->
+      let time = Time.(diff (now ()) start) |! Core.Span.to_float in
+      Lwt_io.printf "{c|%s} {c|%d} {c|%f (%f)}\n"
+        name !reads time (time /. float repetitions)
+    in
+    bench_non_lwt enum_read_counter "{t|File.lines_of |> Enum.hard_count / 4}"
     >>= fun () ->
+    bench_non_lwt enum_transform_counter_with_lines_of
+      "{t|File.lines_of |> Biocaml_fastq.enum_parser |> Enum.hard_count}"
+    >>= fun () ->
+
     Lwt_io.printf "{end}{p}\n"
   ) files
   >>= fun () ->