diff --git a/Makefile b/Makefile index 6b0d931a9a..9cb1e724b9 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ WRAPPER = $(subst run_,,$(RUN_BENCH_TARGET)) PACKAGES = \ cpdf menhir minilight camlimages yojson lwt alt-ergo zarith \ js_of_ocaml-compiler uuidm react ocplib-endian nbcodec checkseum decompress \ - sexplib0 irmin-mem + sexplib0 irmin-mem data-encoding DEPENDENCIES = libgmp-dev libdw-dev jq python3-pip # Ubuntu PIP_DEPENDENCIES = intervaltree diff --git a/benchmarks/data_encoding/de_basic.ml b/benchmarks/data_encoding/de_basic.ml new file mode 100644 index 0000000000..9cd4bed66a --- /dev/null +++ b/benchmarks/data_encoding/de_basic.ml @@ -0,0 +1,37 @@ +let seed = int_of_string Sys.argv.(1) +let width = int_of_string Sys.argv.(2) +let depth = int_of_string Sys.argv.(3) + +let prng = Random.State.make [| seed |] + +type box = {a: int64; b: int32;} +let box_e = + let open Data_encoding in + obj2 + (req "sixty-four" int64) + (req "thirty-two" int32) + +let box () = { + a = Random.State.int64 prng Int64.max_int; + b = Random.State.int32 prng Int32.max_int; +} +let option f () = if Random.State.bool prng then Some (f ()) else None +let rec list n f acc = + if n <= 0 then + acc + else + list (n - 1) f (f () :: acc) +let list n f () = list n f [] + +let t () = list depth (list width (option box)) () + +type t = box option list list +let e = + let open Data_encoding in + list (dynamic_size @@ list (dynamic_size option box_e)) + +let () = + let v = t () in + let b = Data_encoding.Binary.to_bytes_exn e v in + let vv = Data_encoding.Binary.of_bytes_exn e b in + assert (v = vv) diff --git a/benchmarks/data_encoding/dune b/benchmarks/data_encoding/dune new file mode 100644 index 0000000000..fb050bf25c --- /dev/null +++ b/benchmarks/data_encoding/dune @@ -0,0 +1,7 @@ +(executable + (name de_basic) + (modules de_basic) + (libraries data-encoding) +) + +(alias (name buildbench) (deps data_encoding_basic.exe)) diff --git a/dependencies/packages/data-encoding/data-encoding.0.2/opam b/dependencies/packages/data-encoding/data-encoding.0.2/opam new file mode 100644 index 0000000000..e7768da664 --- /dev/null +++ b/dependencies/packages/data-encoding/data-encoding.0.2/opam @@ -0,0 +1,30 @@ +opam-version: "2.0" +maintainer: "contact@nomadic-labs.com" +authors: [ "Nomadic Labs" ] +homepage: "https://gitlab.com/nomadic-labs/data-encoding" +bug-reports: "https://gitlab.com/nomadic-labs/data-encoding/issues" +dev-repo: "git+https://gitlab.com/nomadic-labs/data-encoding.git" +license: "MIT" +depends: [ + "ocaml" { >= "4.07" } + "dune" { >= "1.7" } + "ezjsonm" + "zarith" + "json-data-encoding" { = "0.8" } + "json-data-encoding-bson" { = "0.8" } + "alcotest" { with-test } + "crowbar" { with-test } +] +build: [ + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +synopsis: "Library of JSON and binary encoding combinators" +url { + src: + "https://gitlab.com/nomadic-labs/data-encoding/-/archive/0.2/data-encoding-0.2.tar.gz" + checksum: [ + "md5=c3573f2f066f61437feb6d33d476ee09" + "sha512=d9b95c0b4655930d590a78288edad50fbb845dfff1d2378c11e7f7b2499a70380af2edf289f24145f58c92091195f8326bf51efdb980cd221c22357f9919c37c" + ] +} diff --git a/dependencies/packages/ezjsonm/ezjsonm.1.1.0/opam b/dependencies/packages/ezjsonm/ezjsonm.1.1.0/opam new file mode 100644 index 0000000000..c35b4f85f5 --- /dev/null +++ b/dependencies/packages/ezjsonm/ezjsonm.1.1.0/opam @@ -0,0 +1,36 @@ +opam-version: "2.0" +maintainer: "thomas@gazagnaire.org" +authors: "Thomas Gazagnaire" +license: "ISC" +tags: ["org:mirage" "org:ocamllabs"] +homepage: "https://github.com/mirage/ezjsonm" +doc: "https://mirage.github.io/ezjsonm/" +bug-reports: "https://github.com/mirage/ezjsonm/issues" +depends: [ + "ocaml" {>="4.03.0"} + "dune" {>= "1.0"} + "alcotest" {with-test & >= "0.4.0"} + "jsonm" {>= "1.0.0"} + "sexplib" {< "v0.14"} + "hex" +] +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] +] +dev-repo: "git+https://github.com/mirage/ezjsonm.git" +synopsis: "Simple interface on top of the Jsonm JSON library" +description: """ +Ezjsonm provides more convenient (but far less flexible) +input and output functions that go to and from `string` values. +This avoids the need to write signal code, which is useful for +quick scripts that manipulate JSON. + +More advanced users should go straight to the Jsonm library and +use it directly, rather than be saddled with the Ezjsonm interface. +""" +url { + src: + "https://github.com/mirage/ezjsonm/releases/download/v1.1.0/ezjsonm-v1.1.0.tbz" + checksum: "md5=e8f207c6cd2226b2c4784b1e56556797" +} diff --git a/dependencies/packages/json-data-encoding-bson/json-data-encoding-bson.0.8/opam b/dependencies/packages/json-data-encoding-bson/json-data-encoding-bson.0.8/opam new file mode 100644 index 0000000000..570e4013ef --- /dev/null +++ b/dependencies/packages/json-data-encoding-bson/json-data-encoding-bson.0.8/opam @@ -0,0 +1,27 @@ +opam-version: "2.0" +synopsis: "Type-safe encoding to and decoding from JSON (bson support)" +maintainer: "contact@nomadic-labs.com" +authors: [ "Nomadic Labs" "Ocamlpro" ] +homepage: "https://gitlab.com/nomadic-labs/json-data-encoding" +bug-reports: "https://gitlab.com/nomadic-labs/json-data-encoding/issues" +license: "LGPLv3 w/ linking exception" +dev-repo: "git+https://gitlab.com/nomadic-labs/json-data-encoding" + +build: [ + ["dune" "build" "-j" jobs "-p" name] +] + +depends: [ + "ocaml" {>= "4.03.0"} + "dune" {>= "1.7"} + "json-data-encoding" {= version } + "ocplib-endian" {>= "1.0"} +] +url { + src: + "https://gitlab.com/nomadic-labs/json-data-encoding/-/archive/v0.8/json-data-encoding-v0.8.tar.gz" + checksum: [ + "md5=24fcb7feb10395eaaf840d1f8ccf162f" + "sha512=f6d2a00008a0cd88bfae2458f56dde8f45c4e209ece9805d3e8d2c74401e4a5f9e12f99d5318f58a30a4579d9c9e9f204a75269c2110bb16a3e1036b2599b7a5" + ] +} diff --git a/dependencies/packages/json-data-encoding/json-data-encoding.0.8/opam b/dependencies/packages/json-data-encoding/json-data-encoding.0.8/opam new file mode 100644 index 0000000000..ff6bba6863 --- /dev/null +++ b/dependencies/packages/json-data-encoding/json-data-encoding.0.8/opam @@ -0,0 +1,28 @@ +opam-version: "2.0" +synopsis: "Type-safe encoding to and decoding from JSON" +maintainer: "contact@nomadic-labs.com" +authors: [ "Nomadic Labs" "Ocamlpro" ] +homepage: "https://gitlab.com/nomadic-labs/json-data-encoding" +bug-reports: "https://gitlab.com/nomadic-labs/json-data-encoding/issues" +license: "LGPLv3 w/ linking exception" +dev-repo: "git+https://gitlab.com/nomadic-labs/json-data-encoding" + +build: [ + ["dune" "build" "-j" jobs "-p" name] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] + +depends: [ + "ocaml" {>= "4.03.0"} + "dune" {>= "1.7"} + "uri" {>= "1.9.0" } + "crowbar" { with-test } +] +url { + src: + "https://gitlab.com/nomadic-labs/json-data-encoding/-/archive/v0.8/json-data-encoding-v0.8.tar.gz" + checksum: [ + "md5=24fcb7feb10395eaaf840d1f8ccf162f" + "sha512=f6d2a00008a0cd88bfae2458f56dde8f45c4e209ece9805d3e8d2c74401e4a5f9e12f99d5318f58a30a4579d9c9e9f204a75269c2110bb16a3e1036b2599b7a5" + ] +} diff --git a/run_config.json b/run_config.json index 9889030a21..d22d6d4560 100644 --- a/run_config.json +++ b/run_config.json @@ -1137,6 +1137,22 @@ "params": "" } ] + }, + { + "executable": "benchmarks/data_encoding/de_basic.exe", + "name": "data_encoding_basic", + "ismacrobench": true, + "runs": [ + { + "params": "100 100" + }, + { + "params": "100000 100" + }, + { + "params": "100 100000" + } + ] } ] }