1 package jdk.nashorn.internal.joni.bench;
   2 
   3 public class BenchRailsRegs extends AbstractBench {
   4     public static void main(String[] args) throws Exception {
   5         final String[][] regexps = {{"a.*?[b-z]{2,4}aaaaaa","afdgdsgderaabxxaaaaaaaaaaaaaaaaaaaaaaaa"},
   6                                     {"://","/shop/viewCategory.shtml?category=DOGS"},
   7                                     {"^\\w+\\://[^/]+(/.*|$)$","/shop/viewCategory.shtml?category=DOGS"},
   8                                     {"\\A/?\\Z","/shop/viewCategory.shtml"},
   9                                     {"\\A/shop/signonForm\\.shtml/?\\Z","/shop/viewCategory.shtml"},
  10                                     {"\\A/shop/newAccountForm\\.shtml/?\\Z","/shop/viewCategory.shtml"},
  11                                     {"\\A/shop/newAccount\\.shtml/?\\Z","/shop/viewCategory.shtml"},
  12                                     {"\\A/shop/viewCart\\.shtml/?\\Z","/shop/viewCategory.shtml"},
  13                                     {"\\A/shop/index\\.shtml/?\\Z","/shop/viewCategory.shtml"},
  14                                     {"\\A/shop/viewCategory\\.shtml/?\\Z","/shop/viewCategory.shtml"},
  15                                     {"\\A(?:::)?([A-Z]\\w*(?:::[A-Z]\\w*)*)\\z","CategoriesController"},
  16                                     {"\\Ainsert","SELECT * FROM sessions WHERE (session_id = '1b341ffe23b5298676d535fcabd3d0d7')  LIMIT 1"},
  17                                     {"\\A\\(?\\s*(select|show)","SELECT * FROM sessions WHERE (session_id = '1b341ffe23b5298676d535fcabd3d0d7')  LIMIT 1"},
  18                                     {".*?\n","1b341ffe23b5298676d535fcabd3d0d7"},
  19                                     {"^find_(all_by|by)_([_a-zA-Z]\\w*)$","find_by_string_id"},
  20                                     {"\\.rjs$","categories/show.rhtml"},
  21                                     {"^[-a-z]+://","petstore.css"},
  22                                     {"^get$",""},
  23                                     {"^post$",""},
  24                                     {"^[^:]+","www.example.com"},
  25                                     {"(=|\\?|_before_type_cast)$", "updated_on"},
  26                                     {"^(.*?)=(.*?);","_petstore_session_id=1b341ffe23b5298676d535fcabd3d0d7; path=/"}};
  27         for(String[] reg : regexps) {
  28             new BenchRailsRegs().benchBestOf(reg[0],reg[1],10,1000000);
  29         }
  30     }
  31 }