biniou_vs_binprot.ml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. (******************************************************************************)
  2. (* Copyright © Joly Clément, 2016 *)
  3. (* *)
  4. (* leowzukw@oclaunch.eu.org *)
  5. (* *)
  6. (* Ce logiciel est un programme informatique servant à exécuter *)
  7. (* automatiquement des programmes à l'ouverture du terminal. *)
  8. (* *)
  9. (* Ce logiciel est régi par la licence CeCILL soumise au droit français et *)
  10. (* respectant les principes de diffusion des logiciels libres. Vous pouvez *)
  11. (* utiliser, modifier et/ou redistribuer ce programme sous les conditions *)
  12. (* de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA *)
  13. (* sur le site "http://www.cecill.info". *)
  14. (* *)
  15. (* En contrepartie de l'accessibilité au code source et des droits de copie, *)
  16. (* de modification et de redistribution accordés par cette licence, il n'est *)
  17. (* offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, *)
  18. (* seule une responsabilité restreinte pèse sur l'auteur du programme, le *)
  19. (* titulaire des droits patrimoniaux et les concédants successifs. *)
  20. (* *)
  21. (* A cet égard l'attention de l'utilisateur est attirée sur les risques *)
  22. (* associés au chargement, à l'utilisation, à la modification et/ou au *)
  23. (* développement et à la reproduction du logiciel par l'utilisateur étant *)
  24. (* donné sa spécificité de logiciel libre, qui peut le rendre complexe à *)
  25. (* manipuler et qui le réserve donc à des développeurs et des professionnels *)
  26. (* avertis possédant des connaissances informatiques approfondies. Les *)
  27. (* utilisateurs sont donc invités à charger et tester l'adéquation du *)
  28. (* logiciel à leurs besoins dans des conditions permettant d'assurer la *)
  29. (* sécurité de leurs systèmes et ou de leurs données et, plus généralement, *)
  30. (* à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. *)
  31. (* *)
  32. (* Le fait que vous puissiez accéder à cet en-tête signifie que vous avez *)
  33. (* pris connaissance de la licence CeCILL, et que vous en avez accepté les *)
  34. (* termes. *)
  35. (******************************************************************************)
  36. open Core.Std;;
  37. (* Test which is the faster, to read and write, biniou or core's bin_prot.
  38. * That's not the only criteria, but we need to know *)
  39. open Core_bench.Std;;
  40. (* Common parts *)
  41. type rc_entry = {
  42. commands: (string * int);
  43. }
  44. [@@deriving bin_io];;
  45. type rc_name = string
  46. [@@deriving bin_io];;
  47. type tmp_file = {
  48. rc: (rc_name * (rc_entry list)) list;
  49. daemon: int;
  50. }
  51. [@@deriving bin_io];;
  52. (* XXX Copy to give the same data, marked with another type *)
  53. let tmp_data_bin : tmp_file = {
  54. rc = [
  55. ("./dev1.scm",
  56. [
  57. { commands = ("bump -w daemon,rc,commands /tmp/v033", 1) };
  58. { commands = ("bdmp -w daemon,rc,commands /tmp/v033", 1) };
  59. { commands = ("bdup -w daemon,rc,commands /tmp/v033", 1) };
  60. { commands = ("bdump -aemon,rc,commands /tmp/v033", 1) };
  61. { commands = ("bdump -,commands /tmp/v033", 1) };
  62. { commands = ("bdump -,commands /tmp/v033", 1) };
  63. { commands = ("bdump -p/v033", 1) };
  64. { commands = ("bdump -,commands /tmp/v033", 1) };
  65. { commands = ("bdummmands /tmp/v033", 1) };
  66. { commands = ("echo \"Finish\"", 1) };
  67. { commands = ("free -h", 1) };
  68. { commands = ("du -sh ./_build/src/oclaunch.native", 1) };
  69. { commands = ("task", 1) };
  70. { commands = ("ydump dev.json", 1) }
  71. ]);
  72. ("./dev2.scm",
  73. [
  74. { 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) };
  75. { 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) };
  76. { 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) };
  77. { 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) };
  78. { 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) };
  79. { commands = ("bdump -w daemon,rc,commands /tmp/v033", 1) };
  80. { commands = ("echo \"Finish\"", 1) };
  81. { commands = ("free -h", 1) };
  82. { commands = ("du -sh ./_build/src/oclaunch.native", 1) };
  83. { commands = ("task", 1) };
  84. { commands = ("ydump dev.json", 1) }
  85. ]);
  86. ("lipsum",
  87. ([
  88. { commands = ("Donec in", 1) };
  89. { commands = ("nisl", 1) };
  90. { commands = ("mattis,", 1) };
  91. { commands = ("scelerisque", 1) };
  92. { commands = ("ipsum a,", 1) };
  93. { commands = ("porttitor", 1) };
  94. { commands = ("diam.", 1) };
  95. { commands = ("Vestibulum", 1) };
  96. { commands = ("sed purus", 1) };
  97. { commands = ("at arcu", 1) };
  98. { commands = ("iaculis", 1) };
  99. { commands = ("condimentum.", 1) };
  100. { commands = ("Praesent", 1) };
  101. { commands = ("dictum", 1) };
  102. { commands = ("lacus non", 1) };
  103. { commands = ("justo", 1) };
  104. { commands = ("feugiat", 1) };
  105. { commands = ("sollicitudin.", 1) };
  106. { commands = ("Fusce", 1) };
  107. { commands = ("eleifend", 1) };
  108. { commands = ("malesuada", 1) };
  109. { commands = ("venenatis.", 1) };
  110. { commands = ("Integer", 1) };
  111. { commands = ("fermentum", 1) };
  112. { commands = ("feugiat", 1) };
  113. { commands = ("dui, eu", 1) };
  114. { commands = ("tincidunt", 1) };
  115. { commands = ("dui", 1) };
  116. { commands = ("pharetra", 1) };
  117. { commands = ("ac. Aenean", 1) };
  118. { commands = ("egestas", 1) };
  119. { commands = ("nibh eu", 1) };
  120. { commands = ("dui", 1) };
  121. { commands = ("ultricies", 1) };
  122. { commands = ("gravida.", 1) };
  123. { commands = ("Lorem", 1) };
  124. { commands = ("ipsum", 1) };
  125. { commands = ("dolor sit", 1) };
  126. { commands = ("amet,", 1) };
  127. { commands = ("consectetur", 1) };
  128. { commands = ("adipiscing", 1) };
  129. { commands = ("elit. Cras", 1) };
  130. { commands = ("quis diam", 1) };
  131. { commands = ("accumsan,", 1) };
  132. { commands = ("cursus", 1) };
  133. { commands = ("purus", 1) };
  134. { commands = ("quis,", 1) };
  135. { commands = ("efficitur", 1) };
  136. { commands = ("mi.", 1) };
  137. { commands = ("Vestibulum", 1) };
  138. { commands = ("eleifend", 1) };
  139. { commands = ("nisi", 1) };
  140. { commands = ("risus, ut", 1) };
  141. { commands = ("condimentum", 1) };
  142. { commands = ("orci", 1) };
  143. { commands = ("malesuada", 1) };
  144. { commands = ("a. Nunc", 1) };
  145. { commands = ("risus", 1) };
  146. { commands = ("urna,", 1) };
  147. { commands = ("tempor id", 1) };
  148. { commands = ("dui in,", 1) };
  149. { commands = ("blandit", 1) };
  150. { commands = ("ullamcorper", 1) };
  151. { commands = ("augue.", 1) };
  152. { commands = ("Phasellus", 1) };
  153. { commands = ("ut ex", 1) };
  154. { commands = ("ullamcorper,", 1) };
  155. { commands = ("sollicitudin", 1) };
  156. { commands = ("justo", 1) };
  157. { commands = ("luctus,", 1) };
  158. { commands = ("pharetra", 1) };
  159. { commands = ("felis.", 1) };
  160. { commands = ("Phasellus", 1) };
  161. { commands = ("convallis", 1) };
  162. { commands = ("velit mi.", 1) };
  163. { commands = ("Vestibulum", 1) };
  164. { commands = ("vel dui", 1) };
  165. { commands = ("mauris.", 1) };
  166. { commands = ("Donec", 1) };
  167. { commands = ("vestibulum", 1) };
  168. { commands = ("tempus", 1) };
  169. { commands = ("justo vel", 1) };
  170. { commands = ("pharetra.", 1) };
  171. { commands = ("Cum sociis", 1) };
  172. { commands = ("natoque", 1) };
  173. { commands = ("penatibus", 1) };
  174. { commands = ("et magnis", 1) };
  175. { commands = ("dis", 1) };
  176. { commands = ("parturient", 1) };
  177. { commands = ("montes,", 1) };
  178. { commands = ("nascetur", 1) };
  179. { commands = ("ridiculus", 1) };
  180. { commands = ("mus.", 1) };
  181. { commands = ("Nullam non", 1) };
  182. { commands = ("dui quis", 1) };
  183. { commands = ("tellus", 1) };
  184. { commands = ("pulvinar", 1) };
  185. { commands = ("convallis", 1) };
  186. { commands = ("vel eget", 1) };
  187. { commands = ("mi. Proin", 1) };
  188. { commands = ("aliquet,", 1) };
  189. { commands = ("lorem at", 1) };
  190. { commands = ("auctor", 1) };
  191. { commands = ("volutpat,", 1) };
  192. { commands = ("orci est", 1) };
  193. { commands = ("vehicula", 1) };
  194. { commands = ("diam, in", 1) };
  195. { commands = ("sollicitudin", 1) };
  196. { commands = ("velit", 1) };
  197. { commands = ("massa et", 1) };
  198. { commands = ("diam.", 1) };
  199. { commands = ("Praesent", 1) };
  200. { commands = ("sed diam", 1) };
  201. { commands = ("iaculis,", 1) };
  202. { commands = ("mollis", 1) };
  203. { commands = ("justo sit", 1) };
  204. { commands = ("amet,", 1) };
  205. { commands = ("cursus", 1) };
  206. { commands = ("augue.", 1) };
  207. { commands = ("Quisque", 1) };
  208. { commands = ("ultrices", 1) };
  209. { commands = ("odio ut", 1) };
  210. { commands = ("leo", 1) };
  211. { commands = ("eleifend", 1) };
  212. { commands = ("faucibus.", 1) };
  213. { commands = ("Ut", 1) };
  214. { commands = ("ullamcorper", 1) };
  215. { commands = ("non magna", 1) };
  216. { commands = ("a commodo.", 1) };
  217. { commands = ("Nullam in", 1) };
  218. { commands = ("orci arcu.", 1) };
  219. { commands = ("Nunc", 1) };
  220. { commands = ("iaculis", 1) };
  221. { commands = ("auctor", 1) };
  222. { commands = ("lobortis.", 1) };
  223. { commands = ("Maecenas", 1) };
  224. { commands = ("laoreet", 1) };
  225. { commands = ("imperdiet", 1) };
  226. { commands = ("congue.", 1) };
  227. { commands = ("Nullam", 1) };
  228. { commands = ("pellentesque", 1) };
  229. { commands = ("varius", 1) };
  230. { commands = ("nunc, sed", 1) };
  231. { commands = ("tincidunt", 1) };
  232. { commands = ("nulla", 1) };
  233. { commands = ("luctus et.", 1) };
  234. { commands = ("Integer a", 1) };
  235. { commands = ("risus", 1) };
  236. { commands = ("urna. Nunc", 1) };
  237. { commands = ("in auctor", 1) };
  238. { commands = ("sapien.", 1) };
  239. { commands = ("Nulla", 1) };
  240. { commands = ("pellentesque,", 1) };
  241. { commands = ("orci sit", 1) };
  242. { commands = ("amet", 1) };
  243. { commands = ("efficitur", 1) };
  244. { commands = ("egestas,", 1) };
  245. { commands = ("quam urna", 1) };
  246. { commands = ("tempor", 1) };
  247. { commands = ("nibh, eu", 1) };
  248. { commands = ("varius", 1) };
  249. { commands = ("dolor erat", 1) };
  250. { commands = ("nec ex.", 1) };
  251. ]))
  252. ];
  253. daemon = 2
  254. };;
  255. let tmp_data : Tmp_biniou_t.tmp_file = {
  256. rc = [
  257. ("./dev1.scm",
  258. [
  259. { commands = ("bump -w daemon,rc,commands /tmp/v033", 1) };
  260. { commands = ("bdmp -w daemon,rc,commands /tmp/v033", 1) };
  261. { commands = ("bdup -w daemon,rc,commands /tmp/v033", 1) };
  262. { commands = ("bdump -aemon,rc,commands /tmp/v033", 1) };
  263. { commands = ("bdump -,commands /tmp/v033", 1) };
  264. { commands = ("bdump -,commands /tmp/v033", 1) };
  265. { commands = ("bdump -p/v033", 1) };
  266. { commands = ("bdump -,commands /tmp/v033", 1) };
  267. { commands = ("bdummmands /tmp/v033", 1) };
  268. { commands = ("echo \"Finish\"", 1) };
  269. { commands = ("free -h", 1) };
  270. { commands = ("du -sh ./_build/src/oclaunch.native", 1) };
  271. { commands = ("task", 1) };
  272. { commands = ("ydump dev.json", 1) }
  273. ]);
  274. ("./dev2.scm",
  275. [
  276. { 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) };
  277. { 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) };
  278. { 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) };
  279. { 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) };
  280. { 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) };
  281. { commands = ("bdump -w daemon,rc,commands /tmp/v033", 1) };
  282. { commands = ("echo \"Finish\"", 1) };
  283. { commands = ("free -h", 1) };
  284. { commands = ("du -sh ./_build/src/oclaunch.native", 1) };
  285. { commands = ("task", 1) };
  286. { commands = ("ydump dev.json", 1) }
  287. ]);
  288. ("lipsum",
  289. ([
  290. { commands = ("Donec in", 1) };
  291. { commands = ("nisl", 1) };
  292. { commands = ("mattis,", 1) };
  293. { commands = ("scelerisque", 1) };
  294. { commands = ("ipsum a,", 1) };
  295. { commands = ("porttitor", 1) };
  296. { commands = ("diam.", 1) };
  297. { commands = ("Vestibulum", 1) };
  298. { commands = ("sed purus", 1) };
  299. { commands = ("at arcu", 1) };
  300. { commands = ("iaculis", 1) };
  301. { commands = ("condimentum.", 1) };
  302. { commands = ("Praesent", 1) };
  303. { commands = ("dictum", 1) };
  304. { commands = ("lacus non", 1) };
  305. { commands = ("justo", 1) };
  306. { commands = ("feugiat", 1) };
  307. { commands = ("sollicitudin.", 1) };
  308. { commands = ("Fusce", 1) };
  309. { commands = ("eleifend", 1) };
  310. { commands = ("malesuada", 1) };
  311. { commands = ("venenatis.", 1) };
  312. { commands = ("Integer", 1) };
  313. { commands = ("fermentum", 1) };
  314. { commands = ("feugiat", 1) };
  315. { commands = ("dui, eu", 1) };
  316. { commands = ("tincidunt", 1) };
  317. { commands = ("dui", 1) };
  318. { commands = ("pharetra", 1) };
  319. { commands = ("ac. Aenean", 1) };
  320. { commands = ("egestas", 1) };
  321. { commands = ("nibh eu", 1) };
  322. { commands = ("dui", 1) };
  323. { commands = ("ultricies", 1) };
  324. { commands = ("gravida.", 1) };
  325. { commands = ("Lorem", 1) };
  326. { commands = ("ipsum", 1) };
  327. { commands = ("dolor sit", 1) };
  328. { commands = ("amet,", 1) };
  329. { commands = ("consectetur", 1) };
  330. { commands = ("adipiscing", 1) };
  331. { commands = ("elit. Cras", 1) };
  332. { commands = ("quis diam", 1) };
  333. { commands = ("accumsan,", 1) };
  334. { commands = ("cursus", 1) };
  335. { commands = ("purus", 1) };
  336. { commands = ("quis,", 1) };
  337. { commands = ("efficitur", 1) };
  338. { commands = ("mi.", 1) };
  339. { commands = ("Vestibulum", 1) };
  340. { commands = ("eleifend", 1) };
  341. { commands = ("nisi", 1) };
  342. { commands = ("risus, ut", 1) };
  343. { commands = ("condimentum", 1) };
  344. { commands = ("orci", 1) };
  345. { commands = ("malesuada", 1) };
  346. { commands = ("a. Nunc", 1) };
  347. { commands = ("risus", 1) };
  348. { commands = ("urna,", 1) };
  349. { commands = ("tempor id", 1) };
  350. { commands = ("dui in,", 1) };
  351. { commands = ("blandit", 1) };
  352. { commands = ("ullamcorper", 1) };
  353. { commands = ("augue.", 1) };
  354. { commands = ("Phasellus", 1) };
  355. { commands = ("ut ex", 1) };
  356. { commands = ("ullamcorper,", 1) };
  357. { commands = ("sollicitudin", 1) };
  358. { commands = ("justo", 1) };
  359. { commands = ("luctus,", 1) };
  360. { commands = ("pharetra", 1) };
  361. { commands = ("felis.", 1) };
  362. { commands = ("Phasellus", 1) };
  363. { commands = ("convallis", 1) };
  364. { commands = ("velit mi.", 1) };
  365. { commands = ("Vestibulum", 1) };
  366. { commands = ("vel dui", 1) };
  367. { commands = ("mauris.", 1) };
  368. { commands = ("Donec", 1) };
  369. { commands = ("vestibulum", 1) };
  370. { commands = ("tempus", 1) };
  371. { commands = ("justo vel", 1) };
  372. { commands = ("pharetra.", 1) };
  373. { commands = ("Cum sociis", 1) };
  374. { commands = ("natoque", 1) };
  375. { commands = ("penatibus", 1) };
  376. { commands = ("et magnis", 1) };
  377. { commands = ("dis", 1) };
  378. { commands = ("parturient", 1) };
  379. { commands = ("montes,", 1) };
  380. { commands = ("nascetur", 1) };
  381. { commands = ("ridiculus", 1) };
  382. { commands = ("mus.", 1) };
  383. { commands = ("Nullam non", 1) };
  384. { commands = ("dui quis", 1) };
  385. { commands = ("tellus", 1) };
  386. { commands = ("pulvinar", 1) };
  387. { commands = ("convallis", 1) };
  388. { commands = ("vel eget", 1) };
  389. { commands = ("mi. Proin", 1) };
  390. { commands = ("aliquet,", 1) };
  391. { commands = ("lorem at", 1) };
  392. { commands = ("auctor", 1) };
  393. { commands = ("volutpat,", 1) };
  394. { commands = ("orci est", 1) };
  395. { commands = ("vehicula", 1) };
  396. { commands = ("diam, in", 1) };
  397. { commands = ("sollicitudin", 1) };
  398. { commands = ("velit", 1) };
  399. { commands = ("massa et", 1) };
  400. { commands = ("diam.", 1) };
  401. { commands = ("Praesent", 1) };
  402. { commands = ("sed diam", 1) };
  403. { commands = ("iaculis,", 1) };
  404. { commands = ("mollis", 1) };
  405. { commands = ("justo sit", 1) };
  406. { commands = ("amet,", 1) };
  407. { commands = ("cursus", 1) };
  408. { commands = ("augue.", 1) };
  409. { commands = ("Quisque", 1) };
  410. { commands = ("ultrices", 1) };
  411. { commands = ("odio ut", 1) };
  412. { commands = ("leo", 1) };
  413. { commands = ("eleifend", 1) };
  414. { commands = ("faucibus.", 1) };
  415. { commands = ("Ut", 1) };
  416. { commands = ("ullamcorper", 1) };
  417. { commands = ("non magna", 1) };
  418. { commands = ("a commodo.", 1) };
  419. { commands = ("Nullam in", 1) };
  420. { commands = ("orci arcu.", 1) };
  421. { commands = ("Nunc", 1) };
  422. { commands = ("iaculis", 1) };
  423. { commands = ("auctor", 1) };
  424. { commands = ("lobortis.", 1) };
  425. { commands = ("Maecenas", 1) };
  426. { commands = ("laoreet", 1) };
  427. { commands = ("imperdiet", 1) };
  428. { commands = ("congue.", 1) };
  429. { commands = ("Nullam", 1) };
  430. { commands = ("pellentesque", 1) };
  431. { commands = ("varius", 1) };
  432. { commands = ("nunc, sed", 1) };
  433. { commands = ("tincidunt", 1) };
  434. { commands = ("nulla", 1) };
  435. { commands = ("luctus et.", 1) };
  436. { commands = ("Integer a", 1) };
  437. { commands = ("risus", 1) };
  438. { commands = ("urna. Nunc", 1) };
  439. { commands = ("in auctor", 1) };
  440. { commands = ("sapien.", 1) };
  441. { commands = ("Nulla", 1) };
  442. { commands = ("pellentesque,", 1) };
  443. { commands = ("orci sit", 1) };
  444. { commands = ("amet", 1) };
  445. { commands = ("efficitur", 1) };
  446. { commands = ("egestas,", 1) };
  447. { commands = ("quam urna", 1) };
  448. { commands = ("tempor", 1) };
  449. { commands = ("nibh, eu", 1) };
  450. { commands = ("varius", 1) };
  451. { commands = ("dolor erat", 1) };
  452. { commands = ("nec ex.", 1) };
  453. ]))
  454. ];
  455. daemon = 2
  456. };;
  457. let tmp_base_name = "/tmp/bvsbp"
  458. (* With biniou *)
  459. let serialise_biniou data =
  460. Tmp_biniou_b.string_of_tmp_file data
  461. ;;
  462. let deserialise_biniou data =
  463. Tmp_biniou_b.tmp_file_of_string data
  464. ;;
  465. let biniou () =
  466. serialise_biniou tmp_data
  467. |> deserialise_biniou
  468. (* Compare with source data *)
  469. |> fun read -> assert (read = tmp_data)
  470. ;;
  471. let write_biniou () =
  472. let name = tmp_base_name ^ ".bi" in
  473. serialise_biniou tmp_data
  474. |> (fun data -> Out_channel.write_all ~data name)
  475. ;;
  476. (* With bin_prot *)
  477. let serialise_binprot data =
  478. let module Tmp_bi = struct
  479. type t = tmp_file [@@deriving bin_io]
  480. end in
  481. Binable.to_string (module Tmp_bi) data
  482. ;;
  483. let deserialise_binprot data =
  484. let module Tmp_bi = struct
  485. type t = tmp_file [@@deriving bin_io]
  486. end in
  487. Binable.of_string (module Tmp_bi) data
  488. ;;
  489. let bin_prot () =
  490. serialise_binprot tmp_data_bin
  491. |> deserialise_binprot
  492. (* Compare with source data *)
  493. |> fun read -> assert (read = tmp_data_bin)
  494. ;;
  495. let write_binprot () =
  496. let name = tmp_base_name ^ ".bp" in
  497. serialise_binprot tmp_data_bin
  498. |> (fun data -> Out_channel.write_all ~data name)
  499. ;;
  500. (* Serialise and deserialise data (with checks) *)
  501. let tests = [
  502. "Binou", biniou;
  503. "Bin_prot", bin_prot;
  504. ]
  505. let () =
  506. (* Write files once *)
  507. write_biniou ();
  508. write_binprot ();
  509. (* Run tests *)
  510. List.map tests ~f:(fun (name,test) -> Bench.Test.create ~name test)
  511. |> Bench.make_command
  512. |> Command.run