summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-12-29 01:31:31 -0800
committerOri Bernstein <ori@eigenstate.org>2017-12-29 01:31:31 -0800
commit097c5188b37949e352cb8c92b38c49b4027314e0 (patch)
tree5a3c25ccfd2e5f7d9460d0291091b0da1cd52108 /bench
parent358de40c2f56409ced4d76cd2c4201c609457dac (diff)
downloadmc-097c5188b37949e352cb8c92b38c49b4027314e0.tar.gz
Benchmark matching at end of string.
Diffstat (limited to 'bench')
-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")
+ ;;
+}