File: mocks.ml

package info (click to toggle)
yojson 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,204 kB
  • sloc: ml: 3,436; makefile: 28
file content (26 lines) | stat: -rw-r--r-- 670 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(* chosen by fair dice roll, guaranteed to be large *)
let large = 10_000

let large_int_assoc =
  let ints = List.init large (fun n -> (string_of_int n, `Int n)) in
  `Assoc ints

let data =
  In_channel.with_open_text "bench.json" @@ fun ic -> In_channel.input_all ic

let yojson_data = Yojson.Safe.from_string data

let large_int_list =
  let ints = List.init large (fun n -> `Int n) in
  `List ints

let large_string_list =
  let strings = List.init large (fun n -> `String (string_of_int n)) in
  `List strings

let streamable_string =
  let buf = Buffer.create (large * 100) in
  for i = 1 to large do
    Printf.bprintf buf "%d\n" i
  done;
  Buffer.contents buf