Commits

Sebastien Mondet committed b5b96de

test: add a first benchmark (concatenations)

Comments (0)

Files changed (1)

test/sosa_test.ml

   test_assertf (!been_to_self_sub > 4) "been_to_self_sub: %d" !been_to_self_sub;
   test_assertf (!been_to_none > 4) "been_to_none: %d" !been_to_none;
 
-  ()
+  let () =
+    let implementation = test_name in
+    let experiment = "Concatenate all" in
+    let valid_subjects =
+      List.filter_map test_native_subjects (fun s ->
+          match Str.of_native_string s with
+          | `Ok cs -> Some cs
+          | `Error _ -> None) in
+    let start = Time.(now () |> to_float) in
+    let repeats = 30 in
+    for i = 1 to repeats do
+      let _ =
+        Str.concat ~sep:Str.empty valid_subjects in
+      ()
+    done;
+    let stop = Time.(now () |> to_float) in
+    let result =
+      sprintf "%d strings, %f s" (List.length valid_subjects)
+        ((stop -. start) /. (float repeats)) in
+    Benchmark.add ~implementation ~experiment ~result
+  in
 
+  ()
 
 let utf8_specific_test () =
   let module Utf8 = Int_utf8_character in
     );
   ()
 
-
-
 let () =
   do_basic_test (module struct
       let test_name = "Both natives"