Commits

Sebastien Mondet  committed 69b35b9

Add an BatIO/Enum benchmark, and some system info

  • Participants
  • Parent commits b9ac453

Comments (0)

Files changed (1)

File fastqbench.ml

     in
     loop ())
 
+let enum_read_counter file =
+  let e = BatFile.lines_of file in
+  let count = BatEnum.hard_count e / 4 in
+  count
+
+    
 let do_bench repetitions buffer_sizes files =
   Lwt_io.printf "{section|Benchmark}\n\
-                 {b|Started On %s}\n" Time.(now () |! to_string)
+                 {b|Started On %s}{p}\n" Time.(now () |! to_string)
   >>= fun () ->
   Lwt_io.printf "Info: {list|\n\
                  {*} Repetitions: %d\n\
                  {*} Buffer-sizes: %s\n\
                  {*} Files: {br} %s\n\
-                 }{p}\n"
+                 }{p}{t|$ df hT .}{code}\n"
     repetitions (String.concat ~sep:", " (List.map buffer_sizes (sprintf "%d")))
     (String.concat ~sep:"{br} " (List.map files (sprintf "{t|%s}")))
   >>= fun () ->
+  Lwt_unix.system "df -hT ." >>= fun _ ->
+  Lwt_io.printf "{end}{p}\n{t|$ uname -a}{code}\n" >>= fun () ->
+  Lwt_unix.system "uname -a" >>= fun _ ->
+  Lwt_io.printf "{end}{p}\n" >>= fun () ->
   Lwt_list.iter_s (fun file ->
     Lwt_io.printf "{b|File:} {t|%s}\n\
                    {begin table 3}\n\
-                   {c h|Buf-size}{c h|{#} Reads} {c h|Time (Avg.)}\n" file
+                   {c h|Experiment}{c h|{#} Reads} {c h|Time (Avg.)}\n" file
     >>= fun () ->
     Lwt_list.map_s (fun buffer_size ->
       let reads = ref 0 in
       let time = Time.(diff (now ()) start) in
       return (buffer_size, !reads, Core.Span.to_float time)
     ) buffer_sizes
-    >>= fun results ->
+    >>= fun lwt_io_results ->
     Lwt_list.iter_s (fun (bufs, reads, time) ->
-      Lwt_io.printf "{c|%d} {c|%d} {c|%f (%f)}\n"
+      Lwt_io.printf "{c|Lwt_io (%d B)} {c|%d} {c|%f (%f)}\n"
         bufs reads time (time /. float repetitions))
-      results
+      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}} {c|%d} {c|%f (%f)}\n"
+      !reads time (time /. float repetitions)
     >>= fun () ->
     Lwt_io.printf "{end}{p}\n"
   ) files