Advertisement
BanishMemory

StringSplitter regex tests

May 26th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. import org.junit.BeforeClass;
  2. import org.junit.Test;
  3. import com.carrotsearch.junitbenchmarks.AbstractBenchmark;
  4.  
  5. public class PatternBenchmarkTest extends AbstractBenchmark {
  6.  
  7.     private static String bigS;
  8.     private static StringSplitter pt;
  9.    
  10.     @BeforeClass
  11.     public static void prepare() {
  12.         char[] bigString = new char[10000000];
  13.         for (int i = 0; i < bigString.length; i = i + 2) {
  14.             bigString[i] = 'a';
  15.             bigString[i + 1] = ' ';
  16.         }
  17.         bigS = new String(bigString);
  18.         System.out.println("Created big string");
  19.  
  20.         pt = new StringSplitter();
  21.         System.out.println("Created test class");
  22.     }
  23.  
  24.     @Test
  25.     public void testNonPrecompiled() {
  26.             pt.nonPrecompiledTest(bigS);
  27.     }
  28.  
  29.     @Test
  30.     public void testPrecompiled() {
  31.             pt.precompiledTest(bigS);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement