ref: a2653e75140890d3b29c1ff9f3abc2c281bda1d7
dir: /bench/regex-match.myr/
use std use regex use testr var str var dotstar, hello, world 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) 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], ][:]) } const matchall = {ctx match regex.exec(dotstar, str) | `std.Some m: regex.matchfree(m) | `std.None: std.fatal("Didn't match regex\n") ;; } const searchhello = {ctx match regex.search(hello, str) | `std.Some m: regex.matchfree(m) | `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") ;; }