1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
let rec token buf =
match%sedlex buf with any -> token buf | eof -> () | _ -> assert false
let time f x =
let rec acc f x = function
| 0 -> f x
| n ->
f x |> ignore;
acc f x (n - 1)
in
let t = Sys.time () in
let fx = acc f x 10 in
Printf.printf "Execution time: %fs\n" (Sys.time () -. t);
fx
let () =
let long_str = String.make 1000000 '\n' in
let token_from _ =
let lexbuf = Sedlexing.Latin1.from_string long_str in
(* let () = Sedlexing.set_curr_p lexbuf Lexing.dummy_pos in *)
token lexbuf
in
time token_from long_str
|