Parcourir la source

Add benchmark to compare biniou format and bin_prot one

 + This shows bin_prot is much faster (roughly 5 times) than biniou, an
 argument to consider the transition (#6).
 + Copied code from src to keep it even if it is removed in the future.
 + Create file to preview test data serialised, in "/tmp". Bin_prot is
 smaller too. (See Facts at the end).
 + Awful parts: had to copy the data of the test twice, because I
 couldn't mark tmp_file and Tmp_file_t.tmp_file types as equal.

Facts

Size:
```
4971 /tmp/bvsbp.bi
3254 /tmp/bvsbp.bp
8225 total
```

Results of the test:
```
Estimated testing time 20s (2 benchmarks x 10s). Change using -quota SECS.
┌──────────┬────────────┬─────────┬───────────┬──────────┬────────────┐
│ Name     │   Time/Run │ mWd/Run │  mjWd/Run │ Prom/Run │ Percentage │
├──────────┼────────────┼─────────┼───────────┼──────────┼────────────┤
│ Binou    │ 2_953.12us │  7.96kw │ 2_485.78w │   64.78w │    100.00% │
│ Bin_prot │   645.70us │  3.02kw │   422.23w │   14.23w │     21.86% │
└──────────┴────────────┴─────────┴───────────┴──────────┴────────────┘
```
Leo il y a 8 ans
Parent
commit
c36a3807b6

+ 1 - 0
bench/Makefile

@@ -1,3 +1,4 @@
 all:
 	corebuild -pkg core_bench sprintf_vs_concat.byte
 	corebuild -pkg core_bench swap.byte
+	corebuild -pkg core_bench,yojson,atdgen biniou_vs_binprot.byte

+ 522 - 0
bench/biniou_vs_binprot.ml

@@ -0,0 +1,522 @@
+(******************************************************************************)
+(* Copyright © Joly Clément, 2016                                        *)
+(*                                                                            *)
+(*  leowzukw@oclaunch.eu.org                                                  *)
+(*                                                                            *)
+(*  Ce logiciel est un programme informatique servant à exécuter              *)
+(*  automatiquement des programmes à l'ouverture du terminal.                 *)
+(*                                                                            *)
+(*  Ce logiciel est régi par la licence CeCILL soumise au droit français et   *)
+(*  respectant les principes de diffusion des logiciels libres. Vous pouvez   *)
+(*  utiliser, modifier et/ou redistribuer ce programme sous les conditions    *)
+(*  de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA    *)
+(*  sur le site "http://www.cecill.info".                                     *)
+(*                                                                            *)
+(*  En contrepartie de l'accessibilité au code source et des droits de copie, *)
+(*  de modification et de redistribution accordés par cette licence, il n'est *)
+(*  offert aux utilisateurs qu'une garantie limitée.  Pour les mêmes raisons, *)
+(*  seule une responsabilité restreinte pèse sur l'auteur du programme,  le   *)
+(*  titulaire des droits patrimoniaux et les concédants successifs.           *)
+(*                                                                            *)
+(*  A cet égard  l'attention de l'utilisateur est attirée sur les risques     *)
+(*  associés au chargement,  à l'utilisation,  à la modification et/ou au     *)
+(*  développement et à la reproduction du logiciel par l'utilisateur étant    *)
+(*  donné sa spécificité de logiciel libre, qui peut le rendre complexe à     *)
+(*  manipuler et qui le réserve donc à des développeurs et des professionnels *)
+(*  avertis possédant  des  connaissances  informatiques approfondies.  Les   *)
+(*  utilisateurs sont donc invités à charger  et  tester  l'adéquation  du    *)
+(*  logiciel à leurs besoins dans des conditions permettant d'assurer la      *)
+(*  sécurité de leurs systèmes et ou de leurs données et, plus généralement,  *)
+(*  à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.        *)
+(*                                                                            *)
+(*  Le fait que vous puissiez accéder à cet en-tête signifie que vous avez    *)
+(*  pris connaissance de la licence CeCILL, et que vous en avez accepté les   *)
+(*  termes.                                                                   *)
+(******************************************************************************)
+
+open Core.Std;;
+
+(* Test which is the faster, to read and write, biniou or core's bin_prot.
+ * That's not the only criteria, but we need to know *)
+open Core_bench.Std;;
+
+(* Common parts *)
+type rc_entry = {
+    commands: (string * int);
+}
+[@@deriving bin_io];;
+type rc_name = string
+[@@deriving bin_io];;
+type tmp_file = {
+  rc: (rc_name * (rc_entry list)) list;
+  daemon: int;
+}
+[@@deriving bin_io];;
+
+(* XXX Copy to give the same data, marked with another type *)
+let tmp_data_bin : tmp_file = {
+  rc = [
+    ("./dev1.scm",
+     [
+        { commands = ("bump -w daemon,rc,commands /tmp/v033", 1) };
+        { commands = ("bdmp -w daemon,rc,commands /tmp/v033", 1) };
+        { commands = ("bdup -w daemon,rc,commands /tmp/v033", 1) };
+        { commands = ("bdump -aemon,rc,commands /tmp/v033", 1) };
+        { commands = ("bdump -,commands /tmp/v033", 1) };
+        { commands = ("bdump -,commands /tmp/v033", 1) };
+        { commands = ("bdump -p/v033", 1) };
+        { commands = ("bdump -,commands /tmp/v033", 1) };
+        { commands = ("bdummmands /tmp/v033", 1) };
+        { commands = ("echo \"Finish\"", 1) };
+        { commands = ("free -h", 1) };
+        { commands = ("du -sh ./_build/src/oclaunch.native", 1) };
+        { commands = ("task", 1) };
+        { commands = ("ydump dev.json", 1) }
+     ]);
+    ("./dev2.scm",
+     [
+        { commands = ("Voluptatem occaecati cumque voluptatem voluptatem itaque dolorum. Incidunt voluptas et a qui repellat est omnis. Cupiditate nesciunt perspiciatis dolores laboriosam asperiores ad corporis. Deserunt fugiat nisi est.", 1) };
+        { commands = ("Maxime assumenda quo tempora. Ad necessitatibus quis et possimus saepe. Adipisci doloremque omnis repudiandae. Ad enim qui est nemo. Qui dolorem aut quibusdam fugiat est dolores excepturi aut.", 1) };
+        { commands = ("Earum error est et repudiandae impedit illo explicabo sint. Magni accusamus dolorem animi sed unde soluta ex rerum. Quos voluptas labore quis saepe. Dolorem esse sunt at rerum. Sit non aut dolores sint est nam. Voluptatem autem eos ut voluptate sint dolores.", 1) };
+        { commands = ("Et aut dolorem quam quo minus velit omnis facilis. Rerum quos consectetur velit nihil distinctio in eligendi. Ut optio deserunt et praesentium. Quibusdam veniam laudantium error consequatur.", 1) };
+        { commands = ("Occaecati optio est ut. Ratione et perspiciatis deserunt nihil vitae dignissimos. Tempore animi dolorem aut totam non laboriosam quis in. Pariatur quam pariatur eum. Odit officiis ipsa omnis fugit voluptatem corrupti deleniti. Nemo asperiores commodi quae explicabo temporibus ipsam autem.", 1) };
+        { commands = ("bdump -w daemon,rc,commands /tmp/v033", 1) };
+        { commands = ("echo \"Finish\"", 1) };
+        { commands = ("free -h", 1) };
+        { commands = ("du -sh ./_build/src/oclaunch.native", 1) };
+        { commands = ("task", 1) };
+        { commands = ("ydump dev.json", 1) }
+     ]);
+    ("lipsum",
+     ([
+        { commands = ("Donec in", 1) };
+        { commands = ("nisl", 1) };
+        { commands = ("mattis,", 1) };
+        { commands = ("scelerisque", 1) };
+        { commands = ("ipsum a,", 1) };
+        { commands = ("porttitor", 1) };
+        { commands = ("diam.", 1) };
+        { commands = ("Vestibulum", 1) };
+        { commands = ("sed purus", 1) };
+        { commands = ("at arcu", 1) };
+        { commands = ("iaculis", 1) };
+        { commands = ("condimentum.", 1) };
+        { commands = ("Praesent", 1) };
+        { commands = ("dictum", 1) };
+        { commands = ("lacus non", 1) };
+        { commands = ("justo", 1) };
+        { commands = ("feugiat", 1) };
+        { commands = ("sollicitudin.", 1) };
+        { commands = ("Fusce", 1) };
+        { commands = ("eleifend", 1) };
+        { commands = ("malesuada", 1) };
+        { commands = ("venenatis.", 1) };
+        { commands = ("Integer", 1) };
+        { commands = ("fermentum", 1) };
+        { commands = ("feugiat", 1) };
+        { commands = ("dui, eu", 1) };
+        { commands = ("tincidunt", 1) };
+        { commands = ("dui", 1) };
+        { commands = ("pharetra", 1) };
+        { commands = ("ac. Aenean", 1) };
+        { commands = ("egestas", 1) };
+        { commands = ("nibh eu", 1) };
+        { commands = ("dui", 1) };
+        { commands = ("ultricies", 1) };
+        { commands = ("gravida.", 1) };
+        { commands = ("Lorem", 1) };
+        { commands = ("ipsum", 1) };
+        { commands = ("dolor sit", 1) };
+        { commands = ("amet,", 1) };
+        { commands = ("consectetur", 1) };
+        { commands = ("adipiscing", 1) };
+        { commands = ("elit. Cras", 1) };
+        { commands = ("quis diam", 1) };
+        { commands = ("accumsan,", 1) };
+        { commands = ("cursus", 1) };
+        { commands = ("purus", 1) };
+        { commands = ("quis,", 1) };
+        { commands = ("efficitur", 1) };
+        { commands = ("mi.", 1) };
+        { commands = ("Vestibulum", 1) };
+        { commands = ("eleifend", 1) };
+        { commands = ("nisi", 1) };
+        { commands = ("risus, ut", 1) };
+        { commands = ("condimentum", 1) };
+        { commands = ("orci", 1) };
+        { commands = ("malesuada", 1) };
+        { commands = ("a. Nunc", 1) };
+        { commands = ("risus", 1) };
+        { commands = ("urna,", 1) };
+        { commands = ("tempor id", 1) };
+        { commands = ("dui in,", 1) };
+        { commands = ("blandit", 1) };
+        { commands = ("ullamcorper", 1) };
+        { commands = ("augue.", 1) };
+        { commands = ("Phasellus", 1) };
+        { commands = ("ut ex", 1) };
+        { commands = ("ullamcorper,", 1) };
+        { commands = ("sollicitudin", 1) };
+        { commands = ("justo", 1) };
+        { commands = ("luctus,", 1) };
+        { commands = ("pharetra", 1) };
+        { commands = ("felis.", 1) };
+        { commands = ("Phasellus", 1) };
+        { commands = ("convallis", 1) };
+        { commands = ("velit mi.", 1) };
+        { commands = ("Vestibulum", 1) };
+        { commands = ("vel dui", 1) };
+        { commands = ("mauris.", 1) };
+        { commands = ("Donec", 1) };
+        { commands = ("vestibulum", 1) };
+        { commands = ("tempus", 1) };
+        { commands = ("justo vel", 1) };
+        { commands = ("pharetra.", 1) };
+        { commands = ("Cum sociis", 1) };
+        { commands = ("natoque", 1) };
+        { commands = ("penatibus", 1) };
+        { commands = ("et magnis", 1) };
+        { commands = ("dis", 1) };
+        { commands = ("parturient", 1) };
+        { commands = ("montes,", 1) };
+        { commands = ("nascetur", 1) };
+        { commands = ("ridiculus", 1) };
+        { commands = ("mus.", 1) };
+        { commands = ("Nullam non", 1) };
+        { commands = ("dui quis", 1) };
+        { commands = ("tellus", 1) };
+        { commands = ("pulvinar", 1) };
+        { commands = ("convallis", 1) };
+        { commands = ("vel eget", 1) };
+        { commands = ("mi. Proin", 1) };
+        { commands = ("aliquet,", 1) };
+        { commands = ("lorem at", 1) };
+        { commands = ("auctor", 1) };
+        { commands = ("volutpat,", 1) };
+        { commands = ("orci est", 1) };
+        { commands = ("vehicula", 1) };
+        { commands = ("diam, in", 1) };
+        { commands = ("sollicitudin", 1) };
+        { commands = ("velit", 1) };
+        { commands = ("massa et", 1) };
+        { commands = ("diam.", 1) };
+        { commands = ("Praesent", 1) };
+        { commands = ("sed diam", 1) };
+        { commands = ("iaculis,", 1) };
+        { commands = ("mollis", 1) };
+        { commands = ("justo sit", 1) };
+        { commands = ("amet,", 1) };
+        { commands = ("cursus", 1) };
+        { commands = ("augue.", 1) };
+        { commands = ("Quisque", 1) };
+        { commands = ("ultrices", 1) };
+        { commands = ("odio ut", 1) };
+        { commands = ("leo", 1) };
+        { commands = ("eleifend", 1) };
+        { commands = ("faucibus.", 1) };
+        { commands = ("Ut", 1) };
+        { commands = ("ullamcorper", 1) };
+        { commands = ("non magna", 1) };
+        { commands = ("a commodo.", 1) };
+        { commands = ("Nullam in", 1) };
+        { commands = ("orci arcu.", 1) };
+        { commands = ("Nunc", 1) };
+        { commands = ("iaculis", 1) };
+        { commands = ("auctor", 1) };
+        { commands = ("lobortis.", 1) };
+        { commands = ("Maecenas", 1) };
+        { commands = ("laoreet", 1) };
+        { commands = ("imperdiet", 1) };
+        { commands = ("congue.", 1) };
+        { commands = ("Nullam", 1) };
+        { commands = ("pellentesque", 1) };
+        { commands = ("varius", 1) };
+        { commands = ("nunc, sed", 1) };
+        { commands = ("tincidunt", 1) };
+        { commands = ("nulla", 1) };
+        { commands = ("luctus et.", 1) };
+        { commands = ("Integer a", 1) };
+        { commands = ("risus", 1) };
+        { commands = ("urna. Nunc", 1) };
+        { commands = ("in auctor", 1) };
+        { commands = ("sapien.", 1) };
+        { commands = ("Nulla", 1) };
+        { commands = ("pellentesque,", 1) };
+        { commands = ("orci sit", 1) };
+        { commands = ("amet", 1) };
+        { commands = ("efficitur", 1) };
+        { commands = ("egestas,", 1) };
+        { commands = ("quam urna", 1) };
+        { commands = ("tempor", 1) };
+        { commands = ("nibh, eu", 1) };
+        { commands = ("varius", 1) };
+        { commands = ("dolor erat", 1) };
+        { commands = ("nec ex.", 1) };
+     ]))
+  ];
+  daemon = 2
+};;
+
+let tmp_data : Tmp_biniou_t.tmp_file = {
+  rc = [
+    ("./dev1.scm",
+     [
+        { commands = ("bump -w daemon,rc,commands /tmp/v033", 1) };
+        { commands = ("bdmp -w daemon,rc,commands /tmp/v033", 1) };
+        { commands = ("bdup -w daemon,rc,commands /tmp/v033", 1) };
+        { commands = ("bdump -aemon,rc,commands /tmp/v033", 1) };
+        { commands = ("bdump -,commands /tmp/v033", 1) };
+        { commands = ("bdump -,commands /tmp/v033", 1) };
+        { commands = ("bdump -p/v033", 1) };
+        { commands = ("bdump -,commands /tmp/v033", 1) };
+        { commands = ("bdummmands /tmp/v033", 1) };
+        { commands = ("echo \"Finish\"", 1) };
+        { commands = ("free -h", 1) };
+        { commands = ("du -sh ./_build/src/oclaunch.native", 1) };
+        { commands = ("task", 1) };
+        { commands = ("ydump dev.json", 1) }
+     ]);
+    ("./dev2.scm",
+     [
+        { commands = ("Voluptatem occaecati cumque voluptatem voluptatem itaque dolorum. Incidunt voluptas et a qui repellat est omnis. Cupiditate nesciunt perspiciatis dolores laboriosam asperiores ad corporis. Deserunt fugiat nisi est.", 1) };
+        { commands = ("Maxime assumenda quo tempora. Ad necessitatibus quis et possimus saepe. Adipisci doloremque omnis repudiandae. Ad enim qui est nemo. Qui dolorem aut quibusdam fugiat est dolores excepturi aut.", 1) };
+        { commands = ("Earum error est et repudiandae impedit illo explicabo sint. Magni accusamus dolorem animi sed unde soluta ex rerum. Quos voluptas labore quis saepe. Dolorem esse sunt at rerum. Sit non aut dolores sint est nam. Voluptatem autem eos ut voluptate sint dolores.", 1) };
+        { commands = ("Et aut dolorem quam quo minus velit omnis facilis. Rerum quos consectetur velit nihil distinctio in eligendi. Ut optio deserunt et praesentium. Quibusdam veniam laudantium error consequatur.", 1) };
+        { commands = ("Occaecati optio est ut. Ratione et perspiciatis deserunt nihil vitae dignissimos. Tempore animi dolorem aut totam non laboriosam quis in. Pariatur quam pariatur eum. Odit officiis ipsa omnis fugit voluptatem corrupti deleniti. Nemo asperiores commodi quae explicabo temporibus ipsam autem.", 1) };
+        { commands = ("bdump -w daemon,rc,commands /tmp/v033", 1) };
+        { commands = ("echo \"Finish\"", 1) };
+        { commands = ("free -h", 1) };
+        { commands = ("du -sh ./_build/src/oclaunch.native", 1) };
+        { commands = ("task", 1) };
+        { commands = ("ydump dev.json", 1) }
+     ]);
+    ("lipsum",
+     ([
+        { commands = ("Donec in", 1) };
+        { commands = ("nisl", 1) };
+        { commands = ("mattis,", 1) };
+        { commands = ("scelerisque", 1) };
+        { commands = ("ipsum a,", 1) };
+        { commands = ("porttitor", 1) };
+        { commands = ("diam.", 1) };
+        { commands = ("Vestibulum", 1) };
+        { commands = ("sed purus", 1) };
+        { commands = ("at arcu", 1) };
+        { commands = ("iaculis", 1) };
+        { commands = ("condimentum.", 1) };
+        { commands = ("Praesent", 1) };
+        { commands = ("dictum", 1) };
+        { commands = ("lacus non", 1) };
+        { commands = ("justo", 1) };
+        { commands = ("feugiat", 1) };
+        { commands = ("sollicitudin.", 1) };
+        { commands = ("Fusce", 1) };
+        { commands = ("eleifend", 1) };
+        { commands = ("malesuada", 1) };
+        { commands = ("venenatis.", 1) };
+        { commands = ("Integer", 1) };
+        { commands = ("fermentum", 1) };
+        { commands = ("feugiat", 1) };
+        { commands = ("dui, eu", 1) };
+        { commands = ("tincidunt", 1) };
+        { commands = ("dui", 1) };
+        { commands = ("pharetra", 1) };
+        { commands = ("ac. Aenean", 1) };
+        { commands = ("egestas", 1) };
+        { commands = ("nibh eu", 1) };
+        { commands = ("dui", 1) };
+        { commands = ("ultricies", 1) };
+        { commands = ("gravida.", 1) };
+        { commands = ("Lorem", 1) };
+        { commands = ("ipsum", 1) };
+        { commands = ("dolor sit", 1) };
+        { commands = ("amet,", 1) };
+        { commands = ("consectetur", 1) };
+        { commands = ("adipiscing", 1) };
+        { commands = ("elit. Cras", 1) };
+        { commands = ("quis diam", 1) };
+        { commands = ("accumsan,", 1) };
+        { commands = ("cursus", 1) };
+        { commands = ("purus", 1) };
+        { commands = ("quis,", 1) };
+        { commands = ("efficitur", 1) };
+        { commands = ("mi.", 1) };
+        { commands = ("Vestibulum", 1) };
+        { commands = ("eleifend", 1) };
+        { commands = ("nisi", 1) };
+        { commands = ("risus, ut", 1) };
+        { commands = ("condimentum", 1) };
+        { commands = ("orci", 1) };
+        { commands = ("malesuada", 1) };
+        { commands = ("a. Nunc", 1) };
+        { commands = ("risus", 1) };
+        { commands = ("urna,", 1) };
+        { commands = ("tempor id", 1) };
+        { commands = ("dui in,", 1) };
+        { commands = ("blandit", 1) };
+        { commands = ("ullamcorper", 1) };
+        { commands = ("augue.", 1) };
+        { commands = ("Phasellus", 1) };
+        { commands = ("ut ex", 1) };
+        { commands = ("ullamcorper,", 1) };
+        { commands = ("sollicitudin", 1) };
+        { commands = ("justo", 1) };
+        { commands = ("luctus,", 1) };
+        { commands = ("pharetra", 1) };
+        { commands = ("felis.", 1) };
+        { commands = ("Phasellus", 1) };
+        { commands = ("convallis", 1) };
+        { commands = ("velit mi.", 1) };
+        { commands = ("Vestibulum", 1) };
+        { commands = ("vel dui", 1) };
+        { commands = ("mauris.", 1) };
+        { commands = ("Donec", 1) };
+        { commands = ("vestibulum", 1) };
+        { commands = ("tempus", 1) };
+        { commands = ("justo vel", 1) };
+        { commands = ("pharetra.", 1) };
+        { commands = ("Cum sociis", 1) };
+        { commands = ("natoque", 1) };
+        { commands = ("penatibus", 1) };
+        { commands = ("et magnis", 1) };
+        { commands = ("dis", 1) };
+        { commands = ("parturient", 1) };
+        { commands = ("montes,", 1) };
+        { commands = ("nascetur", 1) };
+        { commands = ("ridiculus", 1) };
+        { commands = ("mus.", 1) };
+        { commands = ("Nullam non", 1) };
+        { commands = ("dui quis", 1) };
+        { commands = ("tellus", 1) };
+        { commands = ("pulvinar", 1) };
+        { commands = ("convallis", 1) };
+        { commands = ("vel eget", 1) };
+        { commands = ("mi. Proin", 1) };
+        { commands = ("aliquet,", 1) };
+        { commands = ("lorem at", 1) };
+        { commands = ("auctor", 1) };
+        { commands = ("volutpat,", 1) };
+        { commands = ("orci est", 1) };
+        { commands = ("vehicula", 1) };
+        { commands = ("diam, in", 1) };
+        { commands = ("sollicitudin", 1) };
+        { commands = ("velit", 1) };
+        { commands = ("massa et", 1) };
+        { commands = ("diam.", 1) };
+        { commands = ("Praesent", 1) };
+        { commands = ("sed diam", 1) };
+        { commands = ("iaculis,", 1) };
+        { commands = ("mollis", 1) };
+        { commands = ("justo sit", 1) };
+        { commands = ("amet,", 1) };
+        { commands = ("cursus", 1) };
+        { commands = ("augue.", 1) };
+        { commands = ("Quisque", 1) };
+        { commands = ("ultrices", 1) };
+        { commands = ("odio ut", 1) };
+        { commands = ("leo", 1) };
+        { commands = ("eleifend", 1) };
+        { commands = ("faucibus.", 1) };
+        { commands = ("Ut", 1) };
+        { commands = ("ullamcorper", 1) };
+        { commands = ("non magna", 1) };
+        { commands = ("a commodo.", 1) };
+        { commands = ("Nullam in", 1) };
+        { commands = ("orci arcu.", 1) };
+        { commands = ("Nunc", 1) };
+        { commands = ("iaculis", 1) };
+        { commands = ("auctor", 1) };
+        { commands = ("lobortis.", 1) };
+        { commands = ("Maecenas", 1) };
+        { commands = ("laoreet", 1) };
+        { commands = ("imperdiet", 1) };
+        { commands = ("congue.", 1) };
+        { commands = ("Nullam", 1) };
+        { commands = ("pellentesque", 1) };
+        { commands = ("varius", 1) };
+        { commands = ("nunc, sed", 1) };
+        { commands = ("tincidunt", 1) };
+        { commands = ("nulla", 1) };
+        { commands = ("luctus et.", 1) };
+        { commands = ("Integer a", 1) };
+        { commands = ("risus", 1) };
+        { commands = ("urna. Nunc", 1) };
+        { commands = ("in auctor", 1) };
+        { commands = ("sapien.", 1) };
+        { commands = ("Nulla", 1) };
+        { commands = ("pellentesque,", 1) };
+        { commands = ("orci sit", 1) };
+        { commands = ("amet", 1) };
+        { commands = ("efficitur", 1) };
+        { commands = ("egestas,", 1) };
+        { commands = ("quam urna", 1) };
+        { commands = ("tempor", 1) };
+        { commands = ("nibh, eu", 1) };
+        { commands = ("varius", 1) };
+        { commands = ("dolor erat", 1) };
+        { commands = ("nec ex.", 1) };
+     ]))
+  ];
+  daemon = 2
+};;
+
+let tmp_base_name = "/tmp/bvsbp"
+
+(* With biniou *)
+let serialise_biniou data =
+  Tmp_biniou_b.string_of_tmp_file data
+;;
+let deserialise_biniou data =
+  Tmp_biniou_b.tmp_file_of_string data
+;;
+let biniou () =
+  serialise_biniou tmp_data
+  |> deserialise_biniou
+  (* Compare with source data *)
+  |> fun read -> assert (read = tmp_data)
+;;
+let write_biniou () =
+  let name = tmp_base_name ^ ".bi" in
+  serialise_biniou tmp_data
+  |> (fun data -> Out_channel.write_all ~data name)
+;;
+
+(* With bin_prot *)
+let serialise_binprot data =
+  let module Tmp_bi = struct
+    type t = tmp_file [@@deriving bin_io]
+  end in
+  Binable.to_string (module Tmp_bi) data
+;;
+let deserialise_binprot data =
+  let module Tmp_bi = struct
+    type t = tmp_file [@@deriving bin_io]
+  end in
+  Binable.of_string (module Tmp_bi) data
+;;
+let bin_prot () =
+  serialise_binprot tmp_data_bin
+  |> deserialise_binprot
+  (* Compare with source data *)
+  |> fun read -> assert (read = tmp_data_bin)
+;;
+let write_binprot () =
+  let name = tmp_base_name ^ ".bp" in
+  serialise_binprot tmp_data_bin
+  |> (fun data -> Out_channel.write_all ~data name)
+;;
+
+(* Serialise and deserialise data (with checks) *)
+let tests = [
+  "Binou", biniou;
+  "Bin_prot", bin_prot;
+]
+
+let () =
+  (* Write files once *)
+  write_biniou ();
+  write_binprot ();
+  (* Run tests *)
+  List.map tests ~f:(fun (name,test) -> Bench.Test.create ~name test)
+  |> Bench.make_command
+  |> Command.run

+ 54 - 0
bench/tmp_biniou.atd

@@ -0,0 +1,54 @@
+(******************************************************************************)
+(* Copyright © Joly Clément, 2014                                             *)
+(*                                                                            *)
+(*  leowzukw@oclaunch.eu.org                                                  *)
+(*                                                                            *)
+(*  Ce logiciel est un programme informatique servant à exécuter              *)
+(*  automatiquement des programmes à l'ouverture du terminal.                 *)
+(*                                                                            *)
+(*  Ce logiciel est régi par la licence CeCILL soumise au droit français et   *)
+(*  respectant les principes de diffusion des logiciels libres. Vous pouvez   *)
+(*  utiliser, modifier et/ou redistribuer ce programme sous les conditions    *)
+(*  de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA    *)
+(*  sur le site "http://www.cecill.info".                                     *)
+(*                                                                            *)
+(*  En contrepartie de l'accessibilité au code source et des droits de copie, *)
+(*  de modification et de redistribution accordés par cette licence, il n'est *)
+(*  offert aux utilisateurs qu'une garantie limitée.  Pour les mêmes raisons, *)
+(*  seule une responsabilité restreinte pèse sur l'auteur du programme,  le   *)
+(*  titulaire des droits patrimoniaux et les concédants successifs.           *)
+(*                                                                            *)
+(*  A cet égard  l'attention de l'utilisateur est attirée sur les risques     *)
+(*  associés au chargement,  à l'utilisation,  à la modification et/ou au     *)
+(*  développement et à la reproduction du logiciel par l'utilisateur étant    *)
+(*  donné sa spécificité de logiciel libre, qui peut le rendre complexe à     *)
+(*  manipuler et qui le réserve donc à des développeurs et des professionnels *)
+(*  avertis possédant  des  connaissances  informatiques approfondies.  Les   *)
+(*  utilisateurs sont donc invités à charger  et  tester  l'adéquation  du    *)
+(*  logiciel à leurs besoins dans des conditions permettant d'assurer la      *)
+(*  sécurité de leurs systèmes et ou de leurs données et, plus généralement,  *)
+(*  à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.        *)
+(*                                                                            *)
+(*  Le fait que vous puissiez accéder à cet en-tête signifie que vous avez    *)
+(*  pris connaissance de la licence CeCILL, et que vous en avez accepté les   *)
+(*  termes.                                                                   *)
+(******************************************************************************)
+
+(* Tmp file is where launch are logged in.
+ * This atd file allow to use biniou easier in tmp file. The purpuse is to save
+ * place, get faster parsing and make harder manual, unwanted modification. A special command line is
+ * available to change current number *)
+
+(* Store values from the configuration file *)
+type rc_entry = {
+    commands: (string * int); (* A list of command, with current number, i.e. number
+    of launches *)
+}
+
+type rc_name = string
+
+(* Source of the file *)
+type tmp_file = {
+  rc: (rc_name * (rc_entry list)) list; (* A list of rc files *)
+    daemon: int; (* The current state of the daemon, maybe by pid *)
+}

+ 353 - 0
bench/tmp_biniou_b.ml

@@ -0,0 +1,353 @@
+(* Auto-generated from "tmp_biniou.atd" *)
+
+
+type rc_name = Tmp_biniou_t.rc_name
+
+type rc_entry = Tmp_biniou_t.rc_entry = { commands: (string * int) }
+
+type tmp_file = Tmp_biniou_t.tmp_file = {
+  rc: (rc_name * (rc_entry list)) list;
+  daemon: int
+}
+
+let rc_name_tag = Bi_io.string_tag
+let write_untagged_rc_name = (
+  Bi_io.write_untagged_string
+)
+let write_rc_name ob x =
+  Bi_io.write_tag ob Bi_io.string_tag;
+  write_untagged_rc_name ob x
+let string_of_rc_name ?(len = 1024) x =
+  let ob = Bi_outbuf.create len in
+  write_rc_name ob x;
+  Bi_outbuf.contents ob
+let get_rc_name_reader = (
+  Ag_ob_run.get_string_reader
+)
+let read_rc_name = (
+  Ag_ob_run.read_string
+)
+let rc_name_of_string ?pos s =
+  read_rc_name (Bi_inbuf.from_string ?pos s)
+let rc_entry_tag = Bi_io.record_tag
+let write_untagged_rc_entry : Bi_outbuf.t -> rc_entry -> unit = (
+  fun ob x ->
+    Bi_vint.write_uvint ob 1;
+    Bi_outbuf.add_char4 ob '\190' 'U' '\176' '\200';
+    (
+      fun ob x ->
+        Bi_io.write_tag ob Bi_io.tuple_tag;
+        Bi_vint.write_uvint ob 2;
+        (
+          let x, _ = x in (
+            Bi_io.write_string
+          ) ob x
+        );
+        (
+          let _, x = x in (
+            Bi_io.write_svint
+          ) ob x
+        );
+    ) ob x.commands;
+)
+let write_rc_entry ob x =
+  Bi_io.write_tag ob Bi_io.record_tag;
+  write_untagged_rc_entry ob x
+let string_of_rc_entry ?(len = 1024) x =
+  let ob = Bi_outbuf.create len in
+  write_rc_entry ob x;
+  Bi_outbuf.contents ob
+let get_rc_entry_reader = (
+  fun tag ->
+    if tag <> 21 then Ag_ob_run.read_error () else
+      fun ib ->
+        let field_commands = ref (Obj.magic (Sys.opaque_identity 0.0)) in
+        let bits0 = ref 0 in
+        let len = Bi_vint.read_uvint ib in
+        for i = 1 to len do
+          match Bi_io.read_field_hashtag ib with
+            | 1045803208 ->
+              field_commands := (
+                (
+                  fun ib ->
+                    if Bi_io.read_tag ib <> 20 then Ag_ob_run.read_error_at ib;
+                    let len = Bi_vint.read_uvint ib in
+                    if len < 2 then Ag_ob_run.missing_tuple_fields len [ 0; 1 ];
+                    let x0 =
+                      (
+                        Ag_ob_run.read_string
+                      ) ib
+                    in
+                    let x1 =
+                      (
+                        Ag_ob_run.read_int
+                      ) ib
+                    in
+                    for i = 2 to len - 1 do Bi_io.skip ib done;
+                    (x0, x1)
+                ) ib
+              );
+              bits0 := !bits0 lor 0x1;
+            | _ -> Bi_io.skip ib
+        done;
+        if !bits0 <> 0x1 then Ag_ob_run.missing_fields [| !bits0 |] [| "commands" |];
+        (
+          {
+            commands = !field_commands;
+          }
+         : rc_entry)
+)
+let read_rc_entry = (
+  fun ib ->
+    if Bi_io.read_tag ib <> 21 then Ag_ob_run.read_error_at ib;
+    let field_commands = ref (Obj.magic (Sys.opaque_identity 0.0)) in
+    let bits0 = ref 0 in
+    let len = Bi_vint.read_uvint ib in
+    for i = 1 to len do
+      match Bi_io.read_field_hashtag ib with
+        | 1045803208 ->
+          field_commands := (
+            (
+              fun ib ->
+                if Bi_io.read_tag ib <> 20 then Ag_ob_run.read_error_at ib;
+                let len = Bi_vint.read_uvint ib in
+                if len < 2 then Ag_ob_run.missing_tuple_fields len [ 0; 1 ];
+                let x0 =
+                  (
+                    Ag_ob_run.read_string
+                  ) ib
+                in
+                let x1 =
+                  (
+                    Ag_ob_run.read_int
+                  ) ib
+                in
+                for i = 2 to len - 1 do Bi_io.skip ib done;
+                (x0, x1)
+            ) ib
+          );
+          bits0 := !bits0 lor 0x1;
+        | _ -> Bi_io.skip ib
+    done;
+    if !bits0 <> 0x1 then Ag_ob_run.missing_fields [| !bits0 |] [| "commands" |];
+    (
+      {
+        commands = !field_commands;
+      }
+     : rc_entry)
+)
+let rc_entry_of_string ?pos s =
+  read_rc_entry (Bi_inbuf.from_string ?pos s)
+let _1_tag = Bi_io.array_tag
+let write_untagged__1 = (
+  Ag_ob_run.write_untagged_list
+    rc_entry_tag
+    (
+      write_untagged_rc_entry
+    )
+)
+let write__1 ob x =
+  Bi_io.write_tag ob Bi_io.array_tag;
+  write_untagged__1 ob x
+let string_of__1 ?(len = 1024) x =
+  let ob = Bi_outbuf.create len in
+  write__1 ob x;
+  Bi_outbuf.contents ob
+let get__1_reader = (
+  Ag_ob_run.get_list_reader (
+    get_rc_entry_reader
+  )
+)
+let read__1 = (
+  Ag_ob_run.read_list (
+    get_rc_entry_reader
+  )
+)
+let _1_of_string ?pos s =
+  read__1 (Bi_inbuf.from_string ?pos s)
+let _2_tag = Bi_io.array_tag
+let write_untagged__2 = (
+  Ag_ob_run.write_untagged_list
+    Bi_io.tuple_tag
+    (
+      fun ob x ->
+        Bi_vint.write_uvint ob 2;
+        (
+          let x, _ = x in (
+            write_rc_name
+          ) ob x
+        );
+        (
+          let _, x = x in (
+            fun ob x ->
+              Bi_io.write_tag ob Bi_io.tuple_tag;
+              Bi_vint.write_uvint ob 1;
+              (
+                let x = x in (
+                  write__1
+                ) ob x
+              );
+          ) ob x
+        );
+    )
+)
+let write__2 ob x =
+  Bi_io.write_tag ob Bi_io.array_tag;
+  write_untagged__2 ob x
+let string_of__2 ?(len = 1024) x =
+  let ob = Bi_outbuf.create len in
+  write__2 ob x;
+  Bi_outbuf.contents ob
+let get__2_reader = (
+  Ag_ob_run.get_list_reader (
+    fun tag ->
+      if tag <> 20 then Ag_ob_run.read_error () else
+        fun ib ->
+          let len = Bi_vint.read_uvint ib in
+          if len < 2 then Ag_ob_run.missing_tuple_fields len [ 0; 1 ];
+          let x0 =
+            (
+              read_rc_name
+            ) ib
+          in
+          let x1 =
+            (
+              fun ib ->
+                if Bi_io.read_tag ib <> 20 then Ag_ob_run.read_error_at ib;
+                let len = Bi_vint.read_uvint ib in
+                if len < 1 then Ag_ob_run.missing_tuple_fields len [ 0 ];
+                let x0 =
+                  (
+                    read__1
+                  ) ib
+                in
+                for i = 1 to len - 1 do Bi_io.skip ib done;
+                (x0)
+            ) ib
+          in
+          for i = 2 to len - 1 do Bi_io.skip ib done;
+          (x0, x1)
+  )
+)
+let read__2 = (
+  Ag_ob_run.read_list (
+    fun tag ->
+      if tag <> 20 then Ag_ob_run.read_error () else
+        fun ib ->
+          let len = Bi_vint.read_uvint ib in
+          if len < 2 then Ag_ob_run.missing_tuple_fields len [ 0; 1 ];
+          let x0 =
+            (
+              read_rc_name
+            ) ib
+          in
+          let x1 =
+            (
+              fun ib ->
+                if Bi_io.read_tag ib <> 20 then Ag_ob_run.read_error_at ib;
+                let len = Bi_vint.read_uvint ib in
+                if len < 1 then Ag_ob_run.missing_tuple_fields len [ 0 ];
+                let x0 =
+                  (
+                    read__1
+                  ) ib
+                in
+                for i = 1 to len - 1 do Bi_io.skip ib done;
+                (x0)
+            ) ib
+          in
+          for i = 2 to len - 1 do Bi_io.skip ib done;
+          (x0, x1)
+  )
+)
+let _2_of_string ?pos s =
+  read__2 (Bi_inbuf.from_string ?pos s)
+let tmp_file_tag = Bi_io.record_tag
+let write_untagged_tmp_file : Bi_outbuf.t -> tmp_file -> unit = (
+  fun ob x ->
+    Bi_vint.write_uvint ob 2;
+    Bi_outbuf.add_char4 ob '\128' '\000' 'c' '\177';
+    (
+      write__2
+    ) ob x.rc;
+    Bi_outbuf.add_char4 ob '\152' '\163' '\253' '\132';
+    (
+      Bi_io.write_svint
+    ) ob x.daemon;
+)
+let write_tmp_file ob x =
+  Bi_io.write_tag ob Bi_io.record_tag;
+  write_untagged_tmp_file ob x
+let string_of_tmp_file ?(len = 1024) x =
+  let ob = Bi_outbuf.create len in
+  write_tmp_file ob x;
+  Bi_outbuf.contents ob
+let get_tmp_file_reader = (
+  fun tag ->
+    if tag <> 21 then Ag_ob_run.read_error () else
+      fun ib ->
+        let field_rc = ref (Obj.magic (Sys.opaque_identity 0.0)) in
+        let field_daemon = ref (Obj.magic (Sys.opaque_identity 0.0)) in
+        let bits0 = ref 0 in
+        let len = Bi_vint.read_uvint ib in
+        for i = 1 to len do
+          match Bi_io.read_field_hashtag ib with
+            | 25521 ->
+              field_rc := (
+                (
+                  read__2
+                ) ib
+              );
+              bits0 := !bits0 lor 0x1;
+            | 413400452 ->
+              field_daemon := (
+                (
+                  Ag_ob_run.read_int
+                ) ib
+              );
+              bits0 := !bits0 lor 0x2;
+            | _ -> Bi_io.skip ib
+        done;
+        if !bits0 <> 0x3 then Ag_ob_run.missing_fields [| !bits0 |] [| "rc"; "daemon" |];
+        (
+          {
+            rc = !field_rc;
+            daemon = !field_daemon;
+          }
+         : tmp_file)
+)
+let read_tmp_file = (
+  fun ib ->
+    if Bi_io.read_tag ib <> 21 then Ag_ob_run.read_error_at ib;
+    let field_rc = ref (Obj.magic (Sys.opaque_identity 0.0)) in
+    let field_daemon = ref (Obj.magic (Sys.opaque_identity 0.0)) in
+    let bits0 = ref 0 in
+    let len = Bi_vint.read_uvint ib in
+    for i = 1 to len do
+      match Bi_io.read_field_hashtag ib with
+        | 25521 ->
+          field_rc := (
+            (
+              read__2
+            ) ib
+          );
+          bits0 := !bits0 lor 0x1;
+        | 413400452 ->
+          field_daemon := (
+            (
+              Ag_ob_run.read_int
+            ) ib
+          );
+          bits0 := !bits0 lor 0x2;
+        | _ -> Bi_io.skip ib
+    done;
+    if !bits0 <> 0x3 then Ag_ob_run.missing_fields [| !bits0 |] [| "rc"; "daemon" |];
+    (
+      {
+        rc = !field_rc;
+        daemon = !field_daemon;
+      }
+     : tmp_file)
+)
+let tmp_file_of_string ?pos s =
+  read_tmp_file (Bi_inbuf.from_string ?pos s)

+ 120 - 0
bench/tmp_biniou_b.mli

@@ -0,0 +1,120 @@
+(* Auto-generated from "tmp_biniou.atd" *)
+
+
+type rc_name = Tmp_biniou_t.rc_name
+
+type rc_entry = Tmp_biniou_t.rc_entry = { commands: (string * int) }
+
+type tmp_file = Tmp_biniou_t.tmp_file = {
+  rc: (rc_name * (rc_entry list)) list;
+  daemon: int
+}
+
+(* Writers for type rc_name *)
+
+val rc_name_tag : Bi_io.node_tag
+  (** Tag used by the writers for type {!rc_name}.
+      Readers may support more than just this tag. *)
+
+val write_untagged_rc_name :
+  Bi_outbuf.t -> rc_name -> unit
+  (** Output an untagged biniou value of type {!rc_name}. *)
+
+val write_rc_name :
+  Bi_outbuf.t -> rc_name -> unit
+  (** Output a biniou value of type {!rc_name}. *)
+
+val string_of_rc_name :
+  ?len:int -> rc_name -> string
+  (** Serialize a value of type {!rc_name} into
+      a biniou string. *)
+
+(* Readers for type rc_name *)
+
+val get_rc_name_reader :
+  Bi_io.node_tag -> (Bi_inbuf.t -> rc_name)
+  (** Return a function that reads an untagged
+      biniou value of type {!rc_name}. *)
+
+val read_rc_name :
+  Bi_inbuf.t -> rc_name
+  (** Input a tagged biniou value of type {!rc_name}. *)
+
+val rc_name_of_string :
+  ?pos:int -> string -> rc_name
+  (** Deserialize a biniou value of type {!rc_name}.
+      @param pos specifies the position where
+                 reading starts. Default: 0. *)
+
+(* Writers for type rc_entry *)
+
+val rc_entry_tag : Bi_io.node_tag
+  (** Tag used by the writers for type {!rc_entry}.
+      Readers may support more than just this tag. *)
+
+val write_untagged_rc_entry :
+  Bi_outbuf.t -> rc_entry -> unit
+  (** Output an untagged biniou value of type {!rc_entry}. *)
+
+val write_rc_entry :
+  Bi_outbuf.t -> rc_entry -> unit
+  (** Output a biniou value of type {!rc_entry}. *)
+
+val string_of_rc_entry :
+  ?len:int -> rc_entry -> string
+  (** Serialize a value of type {!rc_entry} into
+      a biniou string. *)
+
+(* Readers for type rc_entry *)
+
+val get_rc_entry_reader :
+  Bi_io.node_tag -> (Bi_inbuf.t -> rc_entry)
+  (** Return a function that reads an untagged
+      biniou value of type {!rc_entry}. *)
+
+val read_rc_entry :
+  Bi_inbuf.t -> rc_entry
+  (** Input a tagged biniou value of type {!rc_entry}. *)
+
+val rc_entry_of_string :
+  ?pos:int -> string -> rc_entry
+  (** Deserialize a biniou value of type {!rc_entry}.
+      @param pos specifies the position where
+                 reading starts. Default: 0. *)
+
+(* Writers for type tmp_file *)
+
+val tmp_file_tag : Bi_io.node_tag
+  (** Tag used by the writers for type {!tmp_file}.
+      Readers may support more than just this tag. *)
+
+val write_untagged_tmp_file :
+  Bi_outbuf.t -> tmp_file -> unit
+  (** Output an untagged biniou value of type {!tmp_file}. *)
+
+val write_tmp_file :
+  Bi_outbuf.t -> tmp_file -> unit
+  (** Output a biniou value of type {!tmp_file}. *)
+
+val string_of_tmp_file :
+  ?len:int -> tmp_file -> string
+  (** Serialize a value of type {!tmp_file} into
+      a biniou string. *)
+
+(* Readers for type tmp_file *)
+
+val get_tmp_file_reader :
+  Bi_io.node_tag -> (Bi_inbuf.t -> tmp_file)
+  (** Return a function that reads an untagged
+      biniou value of type {!tmp_file}. *)
+
+val read_tmp_file :
+  Bi_inbuf.t -> tmp_file
+  (** Input a tagged biniou value of type {!tmp_file}. *)
+
+val tmp_file_of_string :
+  ?pos:int -> string -> tmp_file
+  (** Deserialize a biniou value of type {!tmp_file}.
+      @param pos specifies the position where
+                 reading starts. Default: 0. *)
+

+ 8 - 0
bench/tmp_biniou_t.ml

@@ -0,0 +1,8 @@
+(* Auto-generated from "tmp_biniou.atd" *)
+
+
+type rc_name = string
+
+type rc_entry = { commands: (string * int) }
+
+type tmp_file = { rc: (rc_name * (rc_entry list)) list; daemon: int }

+ 8 - 0
bench/tmp_biniou_t.mli

@@ -0,0 +1,8 @@
+(* Auto-generated from "tmp_biniou.atd" *)
+
+
+type rc_name = string
+
+type rc_entry = { commands: (string * int) }
+
+type tmp_file = { rc: (rc_name * (rc_entry list)) list; daemon: int }

+ 41 - 0
bench/tmp_biniou_v.ml

@@ -0,0 +1,41 @@
+(* Auto-generated from "tmp_biniou.atd" *)
+
+
+type rc_name = Tmp_biniou_t.rc_name
+
+type rc_entry = Tmp_biniou_t.rc_entry = { commands: (string * int) }
+
+type tmp_file = Tmp_biniou_t.tmp_file = {
+  rc: (rc_name * (rc_entry list)) list;
+  daemon: int
+}
+
+let validate_rc_name = (
+  (fun _ _ -> None)
+)
+let validate_rc_entry : _ -> rc_entry -> _ = (
+  fun _ _ -> None
+)
+let validate__1 = (
+  fun _ _ -> None
+)
+let validate__2 = (
+  fun _ _ -> None
+)
+let validate_tmp_file : _ -> tmp_file -> _ = (
+  fun _ _ -> None
+)
+let create_rc_entry 
+  ~commands
+  () : rc_entry =
+  {
+    commands = commands;
+  }
+let create_tmp_file 
+  ~rc
+  ~daemon
+  () : tmp_file =
+  {
+    rc = rc;
+    daemon = daemon;
+  }

+ 35 - 0
bench/tmp_biniou_v.mli

@@ -0,0 +1,35 @@
+(* Auto-generated from "tmp_biniou.atd" *)
+
+
+type rc_name = Tmp_biniou_t.rc_name
+
+type rc_entry = Tmp_biniou_t.rc_entry = { commands: (string * int) }
+
+type tmp_file = Tmp_biniou_t.tmp_file = {
+  rc: (rc_name * (rc_entry list)) list;
+  daemon: int
+}
+
+val validate_rc_name :
+  Ag_util.Validation.path -> rc_name -> Ag_util.Validation.error option
+  (** Validate a value of type {!rc_name}. *)
+
+val create_rc_entry :
+  commands: (string * int) ->
+  unit -> rc_entry
+  (** Create a record of type {!rc_entry}. *)
+
+val validate_rc_entry :
+  Ag_util.Validation.path -> rc_entry -> Ag_util.Validation.error option
+  (** Validate a value of type {!rc_entry}. *)
+
+val create_tmp_file :
+  rc: (rc_name * (rc_entry list)) list ->
+  daemon: int ->
+  unit -> tmp_file
+  (** Create a record of type {!tmp_file}. *)
+
+val validate_tmp_file :
+  Ag_util.Validation.path -> tmp_file -> Ag_util.Validation.error option
+  (** Validate a value of type {!tmp_file}. *)
+