Skip to content
Browse files

Add Rails regexp benches

git-svn-id: http://svn.codehaus.org/jruby/branches/jruby-reg@5001 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
1 parent 60baa24 commit 8588de5e5e808238cd1738c75a49cab269de6d85 @olabini olabini committed Nov 23, 2007
Showing with 32 additions and 0 deletions.
  1. +1 −0 src/org/rej/bench/AbstractBench.java
  2. +31 −0 src/org/rej/bench/BenchRailsRegs.java
View
1 src/org/rej/bench/AbstractBench.java
@@ -41,6 +41,7 @@ protected void benchBestOf(String _reg, String _str, int warmup, int times) thro
if(time < best) {
best = time;
}
+ System.err.print(".");
}
System.err.println(": " + best + "ms");
}
View
31 src/org/rej/bench/BenchRailsRegs.java
@@ -0,0 +1,31 @@
+package org.rej.bench;
+
+public class BenchRailsRegs extends AbstractBench {
+ public static void main(String[] args) throws Exception {
+ final String[][] regexps = {{"a.*?[b-z]{2,4}aaaaaa","afdgdsgderaabxxaaaaaaaaaaaaaaaaaaaaaaaa"},
+ {"://","/shop/viewCategory.shtml?category=DOGS"},
+ {"^\\w+\\://[^/]+(/.*|$)$","/shop/viewCategory.shtml?category=DOGS"},
+ {"\\A/?\\Z","/shop/viewCategory.shtml"},
+ {"\\A/shop/signonForm\\.shtml/?\\Z","/shop/viewCategory.shtml"},
+ {"\\A/shop/newAccountForm\\.shtml/?\\Z","/shop/viewCategory.shtml"},
+ {"\\A/shop/newAccount\\.shtml/?\\Z","/shop/viewCategory.shtml"},
+ {"\\A/shop/viewCart\\.shtml/?\\Z","/shop/viewCategory.shtml"},
+ {"\\A/shop/index\\.shtml/?\\Z","/shop/viewCategory.shtml"},
+ {"\\A/shop/viewCategory\\.shtml/?\\Z","/shop/viewCategory.shtml"},
+ {"\\A(?:::)?([A-Z]\\w*(?:::[A-Z]\\w*)*)\\z","CategoriesController"},
+ {"\\Ainsert","SELECT * FROM sessions WHERE (session_id = '1b341ffe23b5298676d535fcabd3d0d7') LIMIT 1"},
+ {"\\A\\(?\\s*(select|show)","SELECT * FROM sessions WHERE (session_id = '1b341ffe23b5298676d535fcabd3d0d7') LIMIT 1"},
+ {".*?\n","1b341ffe23b5298676d535fcabd3d0d7"},
+ {"^find_(all_by|by)_([_a-zA-Z]\\w*)$","find_by_string_id"},
+ {"\\.rjs$","categories/show.rhtml"},
+ {"^[-a-z]+://","petstore.css"},
+ {"^get$",""},
+ {"^post$",""},
+ {"^[^:]+","www.example.com"},
+ {"(=|\\?|_before_type_cast)$", "updated_on"},
+ {"^(.*?)=(.*?);","_petstore_session_id=1b341ffe23b5298676d535fcabd3d0d7; path=/"}};
+ for(String[] reg : regexps) {
+ new BenchRailsRegs().benchBestOf(reg[0],reg[1],10,1000000);
+ }
+ }
+}

0 comments on commit 8588de5

Please sign in to comment.
Something went wrong with that request. Please try again.