diff options
author | Ori Bernstein <ori@eigenstate.org> | 2014-10-13 16:10:30 -0400 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2014-10-13 16:10:30 -0400 |
commit | 0b71df23363b948afdb16b5f08dcbc1508278a6b (patch) | |
tree | bdd0e5ffd3abbe9b078ff5a413068aa612bac7f0 /bench | |
parent | 06b12a03f31531fd6783adf4a49a49234da83ca5 (diff) | |
download | mc-0b71df23363b948afdb16b5f08dcbc1508278a6b.tar.gz |
Add regex benchmark.
Diffstat (limited to 'bench')
-rw-r--r-- | bench/Makefile | 3 | ||||
-rw-r--r-- | bench/regex-match.myr | 26 |
2 files changed, 28 insertions, 1 deletions
diff --git a/bench/Makefile b/bench/Makefile index 6adff70..c54922f 100644 --- a/bench/Makefile +++ b/bench/Makefile @@ -4,7 +4,8 @@ BENCHSRC=intsort.myr \ copious-allocs.myr \ sha1-compute.myr \ bigfactorial.myr \ - mandelbrot.myr + mandelbrot.myr \ + regex-match.myr include ../config.mk include ../mk/c.mk diff --git a/bench/regex-match.myr b/bench/regex-match.myr new file mode 100644 index 0000000..a6219d3 --- /dev/null +++ b/bench/regex-match.myr @@ -0,0 +1,26 @@ +use std +use regex + +const main = { + var str, re, i + + str = "€i²æ&±-ŝ€i²æ&±-ŝ€i²æ&±-ŝ€i²æ&±-ŝ€i²æ&±-ŝüüü€i²æ&±-ŝüüü€i²æ&±-ŝü" + 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.Fail m: std.fatal(1, "couldn't compile regex: %s\n", m) + ;; + + match regex.exec(re, str) + | `std.Some m: + | `std.None: std.fatal(1, "Didn't match regex\n") + ;; + + regex.free(re) + ;; +} |