summaryrefslogtreecommitdiff
path: root/bench/regex-match.myr
diff options
context:
space:
mode:
Diffstat (limited to 'bench/regex-match.myr')
-rw-r--r--bench/regex-match.myr12
1 files changed, 11 insertions, 1 deletions
diff --git a/bench/regex-match.myr b/bench/regex-match.myr
index 90b1ead..bb268f2 100644
--- a/bench/regex-match.myr
+++ b/bench/regex-match.myr
@@ -3,7 +3,7 @@ use regex
use testr
var str
-var dotstar, hello
+var dotstar, hello, world
const main = {
str = std.sldup("hello world!")
@@ -11,13 +11,16 @@ const main = {
str = std.strcat(str, str)
str = std.strcat(str, str)
str = std.strcat(str, str)
+ str = std.strcat(str, "x")
dotstar = std.try(regex.compile(".*"))
hello = std.try(regex.compile("hel*o"))
+ world = std.try(regex.compile("wor*l*d!x"))
testr.bench([
[.name="matchall", .fn=matchall],
[.name="searchhello", .fn=searchhello],
+ [.name="searchworld", .fn=searchworld],
][:])
}
@@ -34,3 +37,10 @@ const searchhello = {ctx
| `std.None: std.fatal("Didn't match regex\n")
;;
}
+
+const searchworld = {ctx
+ match regex.search(world, str)
+ | `std.Some m: regex.matchfree(m)
+ | `std.None: std.fatal("Didn't match regex\n")
+ ;;
+}