-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rudi Grinberg <[email protected]> <!-- ps-id: 4c9c0b62-d252-48a0-85e2-8962244825a6 -->
- Loading branch information
Showing
3 changed files
with
43 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
(executable | ||
(libraries re threads core_bench core_unix.command_unix) | ||
(name benchmark)) | ||
(executables | ||
(libraries re core base stdio threads core_bench core_unix.command_unix) | ||
(names benchmark memory)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(* This set of benchmarks is designed for testing re's memory usage rather than | ||
speed. *) | ||
|
||
module Bench = Core_bench.Bench | ||
|
||
let size = 1_000 | ||
|
||
(* a pathological re that will consume a bunch of memory *) | ||
let re = | ||
let open Re in | ||
compile @@ | ||
seq | ||
[ rep (set "01") | ||
; char '1' | ||
; repn (set "01") size (Some size) | ||
] | ||
|
||
let str = "01" ^ String.make size '1' | ||
|
||
let benchmarks = | ||
Bench.Test.create_indexed ~name:"pathological re" ~args:[10; 20; 40; 80; 100; size] (fun len -> | ||
Base.Staged.stage (fun () -> | ||
let len = Int.min (String.length str) len in | ||
ignore (Re.execp ~pos:0 ~len re str) | ||
) | ||
) | ||
|
||
let () = Command_unix.run (Bench.make_command [ benchmarks ]) |