diff --git a/bench/bench.ml b/bench/bench.ml index 349a44b4..99b6fabe 100644 --- a/bench/bench.ml +++ b/bench/bench.ml @@ -25,6 +25,13 @@ let large_string_list = 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 + let main () = Command.run (Bench.make_command [ Bench.Test.create ~name:"JSON reading" (fun () -> @@ -46,6 +53,13 @@ let main () = Bench.Test.create ~name:"JSON writing assoc to channel" (fun () -> Out_channel.with_file "/dev/null" ~f:(fun oc -> ignore (Yojson.Safe.to_channel oc large_int_assoc))); + begin + let buf = Buffer.create 1000 in + Bench.Test.create ~name:"JSON stream roundtrip" (fun () -> + let stream = Yojson.Safe.stream_from_string ~buf streamable_string in + ignore (Yojson.Safe.stream_to_string ~buf stream) + ) + end; ]) let () =