lwt_benchmark.ml 530 B

123456789101112131415161718
  1. open Lwt
  2. let main () =
  3. let toss _ = Lwt.return_unit in
  4. let parser =
  5. match Sys.argv.(1) with
  6. | "http" -> Angstrom.(RFC2616.request >>| fun x -> `Http x)
  7. | "json" -> Angstrom.(RFC7159.json >>| fun x -> `Json x)
  8. | _ -> print_endline "usage: lwt_json_benchmark.native PARSER"; exit 1
  9. in
  10. Lwt_io.resize_buffer Lwt_io.stdin 0x10000 >>= fun () ->
  11. Angstrom_lwt_unix.parse_many parser toss Lwt_io.stdin
  12. >|= function
  13. | _, Ok () -> ()
  14. | _, Error err -> failwith err
  15. ;;
  16. Lwt_main.run (main ())