ocaml-core / base / core / lib_test / core_string_speed_test.ml

open Core.Std

(* let escape = String.Escaping.escape ~escapeworthy:['%';'^'] ~escape_char:'\\'
let escape_gen = String.Escaping.escape_gen ~escapeworthy_map:['%','%';'^','^'] ~escape_char:'\\'

let unescape = String.Escaping.unescape ~escape_char:'\\'
let unescape_gen = String.Escaping.unescape_gen ~map:[] ~escape_char:'\\'

let () =
  let now = Utime.now () in
  for i = 1 to 500_000 do
    ignore (escape_gen
    "foo%bar\\^baz^quux%%%%%%%%%%%%%%%aoeusnthoaeusntaohusoaeusnatohunsaoehusnaoehusnaotusnaoehuasoenuht^^^^^^^^^")
  done;
  let later = Utime.now () in
  prerr_endline (Utime.span_to_string (Utime.abs_diff later now));

  let now = Utime.now () in
  for i = 1 to 500_000 do
    ignore (escape
    "foo%bar\\^baz^quux%%%%%%%%%%%%%%%aoeusnthoaeusntaohusoaeusnatohunsaoehusnaoehusnaotusnaoehuasoenuht^^^^^^^^^")
  done;
  let later = Utime.now () in
  prerr_endline (Utime.span_to_string (Utime.abs_diff later now));



  let now = Utime.now () in
  for i = 1 to 500_000 do
    ignore (unescape_gen
    "foo%bar\\^baz^quux\\s\\s\\s\\s\\s\\s\\s\\s%%%%%%%%%%%%%%%aoeusnthoaeusntaohusoaeusnatohunsaoehusnaoehusnaotusnaoehuasoenuht^^^^^^^^^")
  done;
  let later = Utime.now () in
  prerr_endline (Utime.span_to_string (Utime.abs_diff later now));

  let now = Utime.now () in
  for i = 1 to 500_000 do
    ignore (unescape
    "foo%bar\\^baz^quux\\s\\s\\s\\s\\s\\s\\s\\s%%%%%%%%%%%%%%%aoeusnthoaeusntaohusoaeusnatohunsaoehusnaoehusnaotusnaoehuasoenuht^^^^^^^^^")
  done;
  let later = Utime.now () in
  prerr_endline (Utime.span_to_string (Utime.abs_diff later now)); *)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.