shithub: mc

Download patch

ref: 5566df1184ea0e37b08abe3bf0077998b1f09dd5
parent: c7b5d588f32c4448f134f5702149f3721403959e
author: Ori Bernstein <[email protected]>
date: Mon Oct 13 12:10:30 EDT 2014

Add regex benchmark.

--- a/bench/Makefile
+++ b/bench/Makefile
@@ -4,7 +4,8 @@
 	 copious-allocs.myr \
 	 sha1-compute.myr \
 	 bigfactorial.myr \
-	 mandelbrot.myr 
+	 mandelbrot.myr \
+	 regex-match.myr
 
 include ../config.mk
 include ../mk/c.mk
--- /dev/null
+++ b/bench/regex-match.myr
@@ -1,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)
+	;;
+}