File: buf.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 (19 lines) | stat: -rw-r--r-- 569 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
let main () =
  let buf = Buffer.create 4096 in
  let data = Mocks.large_int_assoc in
  Benchmark.throughputN ~repeat:3 8
    [
      ( "JSON writing with internal buffer",
        (fun () ->
          Out_channel.with_open_bin "/dev/null" (fun oc ->
              ignore (Yojson.Safe.to_channel oc data))),
        () );
      ( "JSON writing with provided buffer",
        (fun () ->
          Out_channel.with_open_bin "/dev/null" (fun oc ->
              ignore (Yojson.Safe.to_channel ~buf oc data))),
        () );
    ]
  |> Benchmark.tabulate

let () = main ()