diff options
author | Ori Bernstein <ori@eigenstate.org> | 2017-09-04 02:58:44 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2017-09-04 02:58:54 -0700 |
commit | 7ef09f3db883c42d01e3b1d80f0d2da6ceff9913 (patch) | |
tree | af370bd4f281a680b9793034f3b5baee1aa43471 /bench/regex-match.myr | |
parent | 40d6f7b5cc0cb9e5de1675a1441ad0dfc0a66bda (diff) | |
download | mc-7ef09f3db883c42d01e3b1d80f0d2da6ceff9913.tar.gz |
Modernize benchmarks.
Diffstat (limited to 'bench/regex-match.myr')
-rw-r--r-- | bench/regex-match.myr | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/bench/regex-match.myr b/bench/regex-match.myr index 47c9264..dd78860 100644 --- a/bench/regex-match.myr +++ b/bench/regex-match.myr @@ -1,26 +1,36 @@ use std use regex +use testr -const main = { - var str, re, i +var str +var dotstar, hello - str = "€i²æ&±-ŝ€i²æ&±-ŝ€i²æ&±-ŝ€i²æ&±-ŝ€i²æ&±-ŝüüü€i²æ&±-ŝüüü€i²æ&±-ŝü" +const main = { + str = std.sldup("hello world!") str = std.strcat(str, str) str = std.strcat(str, str) str = std.strcat(str, str) str = std.strcat(str, str) - for i = 0; i < 100; i++ - match regex.compile(".*") - | `std.Ok r: re = r - | `std.Err m: std.fatal("couldn't compile regex: %s\n", m) - ;; + dotstar = std.try(regex.compile(".*")) + hello = std.try(regex.compile("hel*o")) + + testr.bench([ + [.name="matchall", .fn=matchall], + [.name="searchhello", .fn=searchhello], + ][:]) +} - match regex.exec(re, str) - | `std.Some m: - | `std.None: std.fatal("Didn't match regex\n") - ;; +const matchall = {ctx + match regex.exec(dotstar, str) + | `std.Some m: regex.matchfree(m) + | `std.None: std.fatal("Didn't match regex\n") + ;; +} - regex.free(re) +const searchhello = {ctx + match regex.search(dotstar, str) + | `std.Some m: regex.matchfree(m) + | `std.None: std.fatal("Didn't match regex\n") ;; } |